Skip to main content

Full text of "VIC-20 Personal Computing Guide"

See other formats


Personal Computing on the 



S5.95 






a friendly computer guide 

C^ commadore 

COMPUTER 






*i'' 

&' 



c 
( 



. i« ■; 






.; . f 



\ 



c 

1.', ' . / ( 

( 
c 

- . ( 

•: " ( 
! * - — ( 

^' ( 
( 
( 

( 
( 
( 
( 

:.::.:■■■. -r' ■ < 

( 

Published by ' ' * f 

COMMODORE INTERNATIONAL, LTD. 

Computer Systems Division *•" ( 

950 Rittenhouse Road 

Norrlstown. PA 19403 / . ( 

U.S.A. 

Copyright f 1981 Commodore Inierrrationai and Avafanche Productions. All rights re ^ 

served. No part oi this publication nnay be reproduced, stored in a retrieval system, or 
transmitted m any fonn or by any means, electronic, mechanical, photocopying, recording 

or otherwise without the prior written permission oi Commodore InternationaL 



:■ ^ ■ # / 




- ^-^ 




t'ii^ ' '' 




M^ 




' ^^M> 




1 ,,»kf- ' ^. ^#V V - 




#' \;k ^ 




/;■.;.,•; 'X- ■ 


V 




4 


: / * * •* I' ^ J «. 




.: ,.\< . J. ; ": /% <t 




- ;v/. :- ^ 










4 


.. '•■ ■•• V ;0> 


1 



■y 



■;♦. 



^ , 



( 



PERSONAL 

COMPUTING 

ON THE 



A friendly computer guide^ 



COMMODORE INTERNATIONAL 
AVALANCHE, INC. 
I - 



PREFACE 



( 
C 



You are about to meet a friendly computer^ Friendly in price, 

friendly in size, friendly to use and learn on and experience. ^ 

Most important — you don't tiave to be a computer r 
programmer, or even a typist, to use it ! 

It youVe a first time computerist, this manual will provide an 

excellent introduction to computing. Unlike most instruction ( 

manuals, you don't tiave to read through this whole book to get 

to the "good stuff." After reading Chapter 1 (GETTING C 

STARTED), you can go directly to a chapter that interests you / 

and start reading. If you're interested in animation turn to 

Chapter 4. If you like music, try Chapter 5. ( 

The first page of each chapter has a sample program to start ( 
you off. Just type the program exactly as shown ("Try Typing 

This Program") and see what happens. The rest of the chapter ( 

explains what you did, and shows you how to do more. Chapter ^ 

7 summarizes some important programming concepts, and ^ 

explains the techniques used in the sample programs, ( 

If youYe an experienced programmer, you can use the VIC like r 
any microcomputer. Familiarity with Commodore computers 

will help, since the BASIC and graphics are nearly identical to ( 

those used in the PET/CBM, Advanced reference material and . 

programming information are included in the Appendix. For ^ 

more sophisticated programming, see the VIC PROGRAMMERS ( 
REFERENCE GUIDE, available from your Commodore dealer. 

If you're a noncomputerist and have no interest in 

programming, per se, you should check out the VIC's growing ( 

library of plugnn cartridges and program tapes. VIC cartridges , 

plug directly into the back of the console and work C 

automatically. Programs are also provided on cassette tapes for ( 
use with the Commodore Cassette Tape Recorder. 

Cartridges and tapes include exciting "arcade-type" games ^ 

such as "VIC INVADERS" as well as educational programs to ( 
help you develop special skills, and home utility programs to 

help you solve problems and perform calculations. C 

Peripherals and accessories for the VIC include the VIC tape ( 

cassette recorder, single disk drive, telephone modem and 

printer, to name a few. (See Appendix A) C 

Computers are becoming an fncreasingly important part of our C 

everyday lives — In our homes, at school and in business. . 

Those who become familiar v/ith computers now will have an ^ 

important advantage in the coming months and years. The VIC f 

not only introduces you to the world of computing, but also 

gives you the features and flexibility you need to expand that ( 

world. 

Enjoy your new world! 

II c 



c 

? TABLE OF CONTENTS 

^ CHAPTER TITLE PAGE 

( PREFACE II 

C UNPACKING AND CONNECTING THE VIC20 V 

One GETTING TO KNOW YOUR VIC 1 

• Getting Started 3 

( • Your First Computer Program 7 



( 



c 



c 
c 

c 



Two USINGTHESCREEN AND KEYBOARD 11 



• Your First Graphic Character 14 

C -A Tour of the VIC20 Keyboard 17 

r • Printing on the Screen 21 

• The VIC20 Calculator 24 

C -Introduction to Color 25 

^ Three COLOR AND GRAPHICS 27 

• Programming in Color 30 

{ • The VIC Color Keys 32 

•Changing Screen and Border Colors 34 

• Screen & Border Color Combinations 37 

C •Coloring the Screen 37 

• Screen Locations 39 

• Random Colors 40 



( • Combining Sound and Color 45 

^ • Keyboard Graphics 47 

^ • Graphics in Headlines and Titles 48 



Four ANIMATION 51 



• Flying Birds 53 

• Bouncing Ball 57 

( • Controlling the Cursor 60 

^ • Animating with POKES and PEEKS 61 

( 

c 

( 
c 

C III 



Seven INTRODUCTION TO PROGRAMMING 93 



TITLE PAGE 



INDEX „„„. ,„., , 162 



Five SOUND AND MUSIC .„ 67 

• Making Music ..,. 69 

• The Four Voices of VIC ,„ 71 ^ 

• The White Noise Generator .„... 74 ( 

• Using the VIC as a Piano 76 

• Playing Songs.,. .„.. 78 ■ 

• A Few Words About Poke ...„ , 80 ( 

Six CONVERSING WITH YOUR VIC , .„ 81 ^ 

• What's Your Name? .„. , 83 ^ 

• Introducing Variables ..„„.... 86 ( 

• Choose a Note 88 

•The GET Statement 89 



( 

( 



• Your First BASIC Commands 95 

• Random Numbers 103 ^ 



c 

APPENDIX , __ „ 105 ( 

A. VIC System Accessories , 106 

B. Working With Tape Cassettes ,,.. 109 ^ 

C. VIC BASIC Vocabulary...... 113 ( 

D. BASIC Command Abbreviations 133 

E= Screen and Border Color Combinations............ 134 ^ 

F, Musrcal Notes 135 ( 

G. Sample Sound Effects..... , 136 . 

H. Screen Display Codes ..,.. 139 

I. Screen Memory Map 143 ( 

J. Ascii and Character ($) Codes „., 145 

K. Deriving Mathematical Functions ...,. 148 ^ 

L Pinouts for Input/Output Devices 150 ( 

M. VIC Programs to Try 153 

N. Error Messages 160 ^ 

( 

( 

( 

( 

( 

( 

IV ( 

C 



c 
( 
{ 
( 
( 
( 
( 
{ 
( 
c 
c 
( 
( 
( 
i 
( 
( 
( 
( 
( 
( 
c 

c 

( 
c 

( 

c 
( 
c 
( 
c 
c 

V 



UNPACKING AND CONNECTING 
THE VIC 20 

Welcome to computing! Ttie folfowing sfep-by-step instructions show you how 
to unpack the VIC, connect it to your television set and make sure it's working 
properly. 

Let's begin by taking a quick 
look at the VIC 20: 



KEYBOARD 
(used to type 
information 
and instructions 
into the computer) 



POWER LIGHT 
(glows when your 
VIC is turned on) 




POWER CORD 
SOCKET 
(Attach power 
supply here) 



GAME PORT 
(for joystick 
and other 
game control 
devices) 



ON/OFF 
SWITCH 



EXPANSION 

PORT 

(VIC Program 

cartridges 

plug in here) 




USER PORT 
(For special 
accessories) 



5 PIN 

VIDEO 

PORT 

(For 

connection 

to TV set 

or monitor) 



SERIAL 
PORT 
(For special 

accessories 
like printer, 
disk drive, etc.) 



CASSETTE 
PORT 
(Tape 
cassette 
goes here) 



1. 



8. 



Check the contents of your VIC conlainer. You should find the 
following items; 

— VIC 20 Personal Computer 

— Power Supply (large box with 2 cords coming out of ft) 

— RF Modulator (small metal box) and short cable* 

— Video Cable 

You will need 2 electrtcaf outfets (sockets) — one for the VfC and 
one for your television set. 

Position the VfC ancf Tefevision set so you can use the keyboard 
comfortably while viewing the television screen., .ideally, a labletop 
or desk. 



Find the ON/OFF switch on 
the right hand side of the VIC, 
Make sure it's in the "OFF'' 
posit iori. 

There are two cords coming 
out of the power supply box. 
Plug the power supply cord 
into an electrical outlet and 
plug the other cord into the 
power cord socket on the side 
of the VIC. NOTE: The power 
supply remains "on" while 
plugged in so you should 
unplug it when not in use. 



Connect the video cabie to 
the back of the VIC and to the 
RF Modulator box, as shown. 
Make sure to connect it to the 
video port and nono the Spin 
serial port, which is next to it. 

Connect the RF Modulator to 
your television set. For this 
you' I J need a screwdriver The 
short TV connector cord runs 
from the RF Modulator box to 
the 2 VHP Antenna ieads on 
the back of your television. 
Simply connect the two wires 
to the VHF leads and tighten 
the screws firmly.* 

Turn on the TV seL 




RF MODULATOR 

71 




VIDEO 
PLUG 



CONNECT 

WIRE LEADS 

TO ANTENNA 

LEADS ON 

YOUR TV ^ 

SET 



RF MODULATOR 



VIDEO 
CABLE 

REAR VIEW OF 
TV SET 

^ ®® VHF 

0H 



Note: Some VICs are provided wiih a "switchboK" which attaches beiween ihe RF modulator and TV s*:, 
The switchbox contains a switch with setliriga lor "computer" and TV" and should be set to -canriputef" 
when using I tie ViO 

VI 



C 
C 

c 
c 
( 

c 
c 
( 
c 

( 
( 
( 



( 
( 
( 
( 

( 

( 
( 
( 
<. 
( 
< 

( 

( 
c 
( 
f 
( 
c 



TROUBLESHOOTING CHART 



SYMPTOM 



CAUSE 



REMEDY 



NO PICTURE VIC not ^'on" 

(POWER LIGHT OFF) 



VIC not plugged in 



Power supply not 
plugged in 



Bad fuse in VIC 



Make sure power switch 
IS tn ''on" position 



Check power socket 
next to power switch 



Check connection with 
wait outlet 



Take VIC to your 
Authorized Commodore 
Service Center for 
replacement of fuse' 



NO PICTURE 

(POWER LIGHT ON) (Try turning VIC off for a (ew seconds, then back on) 

TV on wrong channel Check Channel 3 & 4 for 

picture 



Incorrect hookup 



VIC hooks up to "VHP" 
terminals on TV 



Modulator not plugged 
in 



Modulator on wrong 
channel 



Video cable not 
connected 



Clieck connection at 
5'pin Video Port 



Flip switch on Modulator 



Check connection on 
modulator 



PICTURE WITHOUT 
COLOR (TRY TV & 
MODULATOR ON 
CHANNEL 3 & 4) 



Poorly tuned TV 



Retune IV 



PICTURE WITH 
POOR COLOR 



Bad coior adjustment on 
TV (see ^'picture witJiout 
color") 



Adjust coior/Jnue/ 
brightness controls on 
TV 



PICTURE WITH TV volume up too high 

EXCESS (see "picture without 

BACKGROUND NOISE color") 



Adjust volume of TV 



PICTURE OK, 
BUT NO SOUND 



TV volume too low 



Adjust volume of TV 



•The VIC uses a 3 amp SLO-BLO fuse. 

Vll 




10. 



11, 



12. 



Turn on the VIC (the red 
power light on the top of the 
computer should come on). If 
the power light does not. 
consult the accompanying 
troubleshooting chart. 

There is a switch on the RF 
Modulator for selecting either 
Channel 3 or 4. Choose the 
channel with the weaker 
reception in your area^ and set 
tjoth the TV and the 
Modulator to that channel. 
The fine tuning on your 
tefevision may need some 
adjustment. 

Here is what you should see 
on the screen — sometimes it 
takes a second or two to 
activate. If you don't get the 
following display on your 
screen, turn the computer off, 
wait a few seconds and turn it 
on again. 

Adjusting the color and 
tint/hue depends on the color 
controls provided on your 
television set — naturally, 
sets with better controls yield 
better color. Some sets show 
some colors better than 
others. 

If you have trouble with any of 
these steps, consult the 
accompanying 
troubleshooting chart. 



BYTES FREE 



NOW.,. you are ready to start using the VIC, 

NOTE: You can use a monitor instead of a television set — in which case you 
can go directly from the VIC to the monitor cable, without the HF 
Modulator. 



IF ALL ELSE FAILS...CALL THE TOLL-FREE 
COMMODORE TECHNICAL HOTLINE... 

1 ■800-523-5622 



C 

o 

c 

c 

o 

c 

( 

c 

( 

( 

c 

( 

i 



c 

c 



VIII 



( 
( 



Try typing this program: 

Type this program exactly as shown and see 
what happens! 




To stop the progrann, press the 




key. 




C 

( 

C 

c 



GETTING STARTED— 
EXPERIMENT A LITTLE 

You made it! Your VIC is agiow with color and ready for you 
to tell it what to do. The dark blue, blinking rectangle, called 
the cursor, is a signal from the VIC that it is waiting for you. 




VIC TIP: 






[f you type a character on the screen that 


you don't want 


press the 


©'- 






This key will erase Ihe character immedia 


tely to the left o 


f the blink' 


ing cursor. 






Use this key as often as you like to delete 


unwanted characters. 



Now, on with the tour! Begin by pressing the following keys: 

E [R] H [N] m 

See how the cursor moves over one position every time you 
press a key? The cursor tells you where the next character \s 
going to appear on the screen, OK, now find the SHIFT key, it 
looks like this: 




There are two of them, both the same, 

3 



Hold the 
press; 



key down, and while it is being held, 



You can release the ^m^ key after you press the 
The screen should look like this: 



key. 



CBM BASIC V2 
3583 BYTES FREE 
READY. 
PRINT"-- 




Pressing the ^^ key while holding down the 

key caused the quotation mark to appear on the screen. 
Let's continue. Now press the following keys: 

1] s m [N] 1] [o] 



Finally, hold down the 
key once again. The screen 
now shows: 



key, and press the 



'••*CBM BASIC V2 



3583 BYTES FREE 



READY. 

PRINT "RAINBOW" 



'Note: if the nunnber 2 appeared on the screen instead of the 
'■' sign, you didn't hold down the shift key. Hit the 
once to erase the 2 and try again. 




Look for this key: 
Press the 



key and look at the screen. 




Pressing the ^^^^^g key told the VIC you were finished 

typing. The VIC then looked at what you typed, recognized 
that it was being asked to do something (actually, you told it 
to print somethmg). The VIC then PRINTed everything between 
the two quotation marks {RAINBOW}. 

When the VIC finished PRINTing the word RAINBOW, It let 
you know by displaying the READY message and blinking the 
cursor 

Ifs your turn. Go ahead and enter some other PRINT 
messages for your VIC to display. Try these or make up your 
own: 



Press 



here 



E s m [N] m Q E E m m m 




Experiment by using characters other than letters between the 
quote nnarks: The VIC won't mind. Note: If you misspell the 
word PRINT, the VIC will let you know by displaying this 
message on the screen: 



7SYNTAX 
EPROR 



Don't worry. There is absofutely no way you can hurt your VfC 
by typing at the keyboard (unless, of course, you're an 
elephant), but, if you make a mistake, the VIC will help you out 
by calling attention to the error These error messages and 
what they mean are listed in AppendixN. At this point, don't 
worry about the '^SYNTAX ERROR" message. Just keep 
experimenting. 

In no time your screen gets cluttered with all the stuff youVe 
been typing. The VIC has a handy way to CLeaR up this clut- 
ter. To tell the VIC to "clear" the screen, do the following: 



Hold down the 
the ra key. 



key and press 
IMPORTANT 




The screen clears instantly; everything you and the VIC have 
typed disappears. You are left with a clean white display area 
and a blue cursor blinking away in the upper left hand corner. 

Remember how you told the VIC to do this feat. Clearing up 
the screen is one of the more frequent commands you'll be 
using as you get to know your VIC. 



c 
c 

c 
( 
( 
( 

c 

# 
c 
( 
( 
( 
c 

c 
c 
( 
( 
( 
c 
«' 

( 

c 
(. 
( 
( 
c 



YOUR FIRST 
COMPUTER "PROGRAM" 

If your VIC performed well in displaying your messages, no 
nnatter how bizarre they might have been, then your computer 
is probably ready to do iust about anything. Let^s begin by 
"entering" your first computer program. 

STEP 1; Clear the screen by holding 
down the ^^^H key and 

then pressing the BTl key. 
STEP 2: Type: [n] \E} [W] and press the 



STEP 3: Type: [T\[0\ [ESHflHE] 

and press 



STEP 4: Type: [2j [O^ 




Q] {q} and press 




VIC TIP: EDITING MISTAKES IN A PROGRAM 

If you make a mistake on a line, you have these editing options: 

1, You can retype a fine anytime and the VIC will automatically 
substitute the new line for the old one. For example, if your pro- 
gram looKs like tfiis: ^p***'^^^^^^ ^^.y^>y-^^^"\^ 

10PRINN ■'VIC20" \^ mistake^ 



1( 



} 10 ^^"-^^^^^J^ 



a tew times and type: 



20 GOTO 

You can sktp down by flitting 

10 PRINT 'VIC20 

Now, the new line has replaced the old line and the program ^ill 
"run^". To make sure, type ClIQEIl] ■ R^P'^^ing lines in a pro^ 
gram is also a quick and easy way to experiment* 

2. You can er ase an unwant ed fine by typing the number of that line 

and hitting ^^^^^^H ^ The entire line will be erased from 
memory, ^^mum^^ 

3. You can edit a ffne by using the cursor keys to move to the 
character(s) in the line of a program you want to change, typing in 

. Note that quota- 



a program over them and hitting 

tion marks sometimes contuse the VIC— if you get unwanted 
characters after quote marks, 90 back to the beginning of the line 
and type it over. 



4. The INST key (get it by typing 



) lets you 



insert characters by opening up spaces in a word or line you've 
already typed. 



5. The DELETE key (just type miM ) erases charactere Imme- 
diately to the left of the cursor 



If everything looks all rigfit to you, type the following word, ( 

and press ^^^^^H ( 

[r] rCn nsH ^^^H here C 



The screen should fill with VIC20. At times, it looks like small 
animated letters traveling up the screen. 



C 
C 
C 
C 
C 



VIC20VIC20VIC20VIC20VIC20Vi( 
IC20VIC20VIC20VIC20VIC20ViC20^ 
320VIC20VIC20VIC20VfC20VIC20V 
20VIC20VIC20VIC20VIC20VIC20V 
JVIC20VIC20VIC20VIC20VIC20VI 
'IC20VIC20VIC20VIC20VIC20VIC20* 
C20VIC20VIC20VIC20VIC20V1C20V 
20VIC20VIC20 VI C20VI C20VI C20V 
OVIC20VIC20VIC20ViC20VIC20VI 
'IC20VIC20VIC20VIC20V1C20VIC20^ 
'IC20VIC20VICaOVIC20VIC20VIC20\ 
'IC20VIC20VIC20VIC20VIC20VIC20* 



Want to slow down the program? Press the key on the left 
side of the keyboard marked: 



If you hold down the Hill key, the program stows down. 

Amazing! Your VIC is full of wonderful features. Here, with 
just a single key, you are telling the VIC to reduce how fast it 
is displaying stuff on the screen. 

Yes, but how do you STOP the program? Good question. Look 
around the keyboard until you find this key: ffffB 



Press the gygg key. The program should stop, and the 
message: 

BREAK IN 10 
READY 

should appear on the screen. (Don't worry, you didn't break 
the VIC— "break" means "stop" in VIC language). Also, the 
cursor should reappear. Did you notice that it was gone while 
it was printing? 

Now, let's take a look at your program and see if it's still 
there. Try typing this: 

[L][i][s]m^^B 

Your program (lines TO and 20) will be displayed on the screen. 
Now type RUN and the program will 'Vun" again, 

9 



You have just been introduced to several aspects of the VIC 
that you will use in many of the later chapters. You have: 

• PRINTed messages on the screen. 

• CLeaRed the screen (SHIFT CLR keys). 

• Written your first program (VIC20) and created a moving 
display. 

• Slowed down (ConTRoLed) the program (the CTRL key). 

• STOPed the program with the STOP key (RUN /STOP key). 

• LISTed the program, 

• Learned some easy ways to edit what you type. 

As you explore the chapters of this guide, you will find many 
uses for what you have seen here. Don't worry if you have 
unanswered questions at this point. Just go ahead and experi- 
ment and most of your questions will be answered as you go r 
along. 

This guide is designed so that you can go directly to any ^ 

crtapfer that looks interesting to you. You do not have to read ™ 

each chapter in order to get to know your VIC. Just be sure to Q 
start from the beginning of each chapter. You will find that our 

gradual introduction to each topic makes it easier for you to C 



learn how to create adventures of your own. Enjoy 



o- 



10 



C 

c 
( 
( 

• 

c 

c 

c 

# 

c 

( 

c 

( 

( 
( 

( 

c 




Using the 
Screen and 
Keyboard 



Your First Graphic 
Character 

A Tour of the 
VIC 20 Keyboard 

Printing on the 
Screen 

The VIC 20 
Calculator 

Introduction to Color 



Try typing this program: 

Type this program exactly as shown and see 
what happens! 



10 PRINT 



20 FOR T=1 TO 300: NEXT 
30 PRINT "your name" 
40 FOR T = 1 TO 300: NEXT 
50 GOTO 10 



Type: [r] [u] [n] and hit 

To Stop the program, press the 




key. 




12 



c 
• 
c 
c 
c 
c 
c 
c 
c 
c 
c 
c 
c 
( 
( 
c 
c 
c 
c 

( 
( 

c 
c 
( 
( 
( 
( 
( 
( 
( 
a 



USING THE SCREEN AND 
KEYBOARD 

This Chapter assumes that youVe read and understood Chapter 
1: Getting to Know Your VIC. If you have not, go back and read 
at least the last two sections which show you how to use the 
keyboard to control what the VIC prints on the screen. 

To start, poise yourself before the VIC keyboard and type as 
follows, including the progrann line nunnbers and punctuation 
marks; 



Hold down the |j^^| key and press the mm key. 
[M] m @ ^rid press the ^^^^^| key. 




and press 

\2} [G][0]lT][0] m 

and press 
[R] [U] [n] and press 

When you type RUN, the screen should fill with the word: 

HELLO 

The words appear to be moving up and sideways! Press the 
CTRL key to slow things a bit. The VIC is PRtNTing the 
message several times near the bottom of the screen. When 
the screen fills, the contents of the screen are moved up to 
make room for more PRINTing. So, the upward movement is 
really happening. The "barber pole effect" is an 'Illusion" 
caused by the number of characters the VIC is putting in each 
line. 

To stop this program, press this key: 



13 



Now, it's your turn. Type these two lines: 

hIHIe 1] [DEH0E11BB [o][your nameJQQ:] 



and press 

[r] [U] [^ and press I 



-Put your y The semicolon 
name here.T ^neans print 

everything next 
to each other. 



Wow! Now that you're a TV star, what does your name do on 
the screen? The ^Illusion" of movement depends on the 
number of characters in the message. 

Again, when you want to stop the action, press the |^ key. 

YOUR FIRST 
GRAPHIC CHARACTER 



Clear the scree n (hold down ■■■^ and Wi3 ), Now 
tyP^ BHIiB A^D [S] , You should get a blue heart on the 



screen. Try it again. You have just typed your first graphic 
character. 



Try typing other graphics. Now hold down the ^H key and 
type some graphics — this Is the left side graphics set. Left 
side graphics are very good for designing business forms, 



charts and graphs. Typing the K^^H and i,<3 keys at 

the same time lets you use upper and lower case letters. See 
Chapter 3 for an explanation. 

SIZE OF THE SCREEN 

How big is the screen on the VIC? Let's find out. Do this: Clear 
the screen and type the following: 



and press 



mEsmumQHQa 




2] 1] m B [0] H 



EES 



•m 



6 
C 
C 

c 
( 
c 
c 
c 

( 
c 
c 
c 
c 
( 
c 
( 
c 

( 
( 
c 
c 

c 
• 
c 
c 

( 

( 



c 
c 
c 
( 
( 
c 
( 
( 
( 
( 
( 
c 
c 
( 
( 
( 
( 
( 
( 
( 
( 
( 
c 
c 
c 
( 
( 
c 
c 
( 
( 
( 
( 

c 



The screen will fill with blue hearts! Count the number of 
hearts being printed across the screen. There are 22 of them in 
each row. The VIC has 22 PRINT positions across the screen, 
The positions across the screen are sometimes called columns. 
The VIC has 22 columns. 



How many positions are there down the screen? Press the 
key to slow down the PRINTing. Holding the ^Q key 

causes the last four rows to "flash". The VIC has 23 rows 
down the screen. 



COLUMN 





15 



The VIC has 506 places on the screen for characters, letters, 
symbols, and so forth. You might say that the VIC can juggle 
506 characters at the same time. Amazing! 



VIC TIP 

If the VIC has 22 columns across the screen, then any message whose 
length is an even divisor of 22 (messages 2 characters. 11 and 22 
characters in length) causes the VJC to PRINT in nice neat columns. 
Messages of other lengths spill over to the next Jine, Test this assump- 
tion for yourself. 



C 

o 
c 
c 





Stop the VfC's PRINTing of the neat columns of hearts by 
pressing the Mntj key. Then enter these two lines into the VIC. 




[T]E[R][I][N][T]0 1P0[D 



You can change the way information rs printed on the screen 
by putting spaces between the quotation marks. Another way is 
to use periods (or dots) instead of spaces. Try typing your name 
and 3 periods in the program at the beginning of this chapter. 



c 
c 
c 
c 
c 
( 
( 
c 

c 
c 
c 



16 



c 

c 

c 



A TOUR OF THE 
VIC20 KEYBOARD 






You have now used the keyboard to create and PRINT 
messages, put graphics characters on the screen, control the 



flow of what the VIC is doing ( g3 and f^ }, and 
possibly edit what you have typed { 



Time now for an extended tour of the keyboard and what it can 
do for you. Consult the diagram above for the powerful and 
versatile set of VIC20 keys. 



RESTORE 



This is a ^'reset" key. ^^^^^^ 

If you type the RUN/STOP key and the ^^^HM key 
together, you completely reset the computer as if you just 
turned it on. ..with the benefit that any programs you had in the 
memory are retained and can be listed or run from the start. 



17 





c 
c 
( 
c 
( 
( 

SHIFT keys — The VIC keyboard is just like a 
typewriter and has two shift keys and a ( 

SHIFT LOCK key. The SHIFT key is used with ( 

other keys to type graphics characters and perform operations 
like clearing the screen. C 

CLR-HOME key — Press this key and the ^ 

cursor moves to the top left-hand corner of ( 

the screen (the ''home" position). If you hold 

down the SHIFT key and press this key, the cursor still moves ( 

to the home position, but you also clear the screen. 

CRSR keys — With the VIC, you can easily ( 

move the cursor up, down and sideways. The 
CRSR keys have a repeat feature that keeps ( 

the cursor moving until you release the key. Each key has a set / 

of arrows that tell you the directions the key controls-— up and 
down or sideways. To move the cursor down or to the right, you { 

simply press the appropriate key. To move up or to the left, you 
must hold down the SHIFT key while pressing the appropriate C 

CRSR key. It is significant to keep in mind that you can move the r 

cursor over the tops of characters on the screen without affect- 
ing those characters. ( 





RETURN 



RETURN key — You press RETURN at the ^ 

end of each line of instruction. Pressing this r 
key tells the VIC to enter the fine, or to 

execute the instruction(s). Sometimes it helps to think of C 
RETURN as an ENTER key because this key actually enters the 

information or instruction into the computer. f 

CTRL key — This key is used with the 

COLOR keys to select the coiors that you C 

create on the VIC screen. The key also ^ 

provides you with the ability to define your own control ^^ 

commands that can be incorporated into any applications you (^ 
might develop for the VIC, Some plugnn cartridges will make 

use of the Control key to perform special functions. The CTRL C 

key works like the SHIFT key. You must hold it down while . 

pressing the color key. ^ 

18 ( 

r 





BLK\/WHT\/ RED\/nVft] \/ PUR\/GRM\/ 8LU\/ YEL 



COLOR keys — You can change the colors of the characters 
displayed by simultaneously pressing the CTRL key and one of 
the 8 color/number keys on the top row of the keyboard. A 
shorthand notation for each color is shown on the face of the 
keys. The colors are black, white, red, cyan (light blue), purple, 
green, blue, and yellow. With these keys, you can set or change 
the color of letters, numbers and graphics displayed inside or 
outside a computer program. Once you "set'' a color, everything 
you type will be in that color until you change colors again. 

Ky^b RVS ON and RVS OFF keys ^ You can 
tS^XwaS^w ^^^^^^^ ^^^ images that the VIC puts on the 
MSSwMSoiV screen by typing CTRL and RVS ON. Every- 
thing you type will then be re versed... for example, you can 
make the VIC display white characters on a blue background 
(the opposite of what it normally prints) by pressing CTRL and 
RVS ON. To get back to normal type CTRL and RVS OFF, Try it! 

RUN-STOP key — Press this key to tell the 
VIC to stop what it is doing and return control 
back to you. When the VIC is running a 
program, you can stop the program with this key. Holding down 
the SHIFT and pressing this key, tells the VIC to begin loading 
information into memory from the optional tape cassette unit. 

IN ST- DEL key — You can insert and delete 
characters from the line you are typing by 
pressing this key. When you press the key by 
itself (delete), the character that was immediately to the left of 
the cursor disappears. If you're in the middle of a line, the 
character to the left is deleted and the characters to the right 
automatically move in to close up the space. Holding down 
SHIFT and pressing this key, opens up a space in the line so 
you can insert a new character. This is very powerful for editing 
and correcting mistakes! 

GRAPHICS & THE COMMODORE KEY — 

When you turn on the VIC, you're 
automatically in ''graphics'' mode which 
means you can type UPPER CASE letters and the more than 60 
graphics you see on the keys. There are two graphics on each 
key. To get the graphic on the right side, simply hold down the 
SHIFT key and type the key with the graphic you want. To get 
the graphics on the left side, hold down the "COMMODORE" 
key (the little f4ag). In this way you can type UPPER CASE 
letters and the full graphics set at the same time! You can 
create pictures, charts, and designs by placing characters side 
by side or on top of each other (like building bfocks). 

19 






^^Oig^^gg^^ ^^ 



» 



» 



^ 



l» 



c 



c 



c 
c 

c 
c 

UPPER/LOWER CASE and GRAPHICS keys — if you press the * 

SHIFT and COMMODORE keys at the same time, you put the 

VIC into a text mode. You can then use the VIC like an ordinary C 

typewriter, with full upper and lower case letters, plus all the 

graphics on the left side of the keys. The left side graphics are 

ideal for creating charts, graphs, and business forms. To get ( 

back into ''Upper Case/Full Graphics" mode, press the SHIFT _ 

and COMMODORE keys together. C 

C 

PROGRAMMABLE FUNCTION KEYS — The ^ 

four tan keys on the right side of the console r 

are not defined when you turn on the VIC. 
They can be assigned tasks or functions from ( 

Within the applications that you create. By 
using these keys with and without SHIFT, you 
get a total of eight assignable function keys. ^ 

Function keys will be mostly used with plug- 
in cartridges containing special programs, ( 
but computer programmers can assign these ^ 
keys as well ^ 

c 

SPECIAL KEYS — The VIC keyboard also contains special 

symbols not found on many typewriters, or even most ^ 

computers. Examples are the English "pound'' sign ( £ ), pi 

( TT ), back arrow { -<— }, up arrow ( f ), greater/lesser than 

( > < ), and brackets ([ I) ( 

This concludes your tour of the VIC keyboard. Using only C 

words, it's difficult to convey just how flexible and powerful the r 

VIC keyboard is. The best way to discover everything the VIC 

can do is to begin your own "touring". Experiment with the Q 

keyboard. Try out the various upper/lower case features 

mentioned above. See what you can create with the rich VIC 

graphics set. The keyboard is your direct link to the VIC. ^ 

Knowing the Keyboard will help you know your VIC 20. 

c 

20 ^ 



c 



C 



Clear the screen and enter the following lines: 

new! 



PRINT "A^', '^B** 



The screen shows: 




Now, enter this line and press 
The screen now shows: 



: PRINT 'W^; "B" 



NEW 
READY 
PRINT "A", "B* 



READY. 
PRINT "A"; "B" 



READY. 




21 



When the comma was used in the first PRfNT statement, the 
VIC placed the letters on the screen, but separated them by 
several spaces. When the semicolon was used, the VIC 
displayed the two letters close together. 

In the first case, the letters are exactly 11 spaces apart. That 
fact gives a clue to what's happening. The VIC divides the 
screen area into two equal parts, 

Whenthe VIC is PRINTing two messages or numbers separated 
by a comma, it puts the first item on the left side of the screen 
and the second on the right.. 




UNLESS 



The first item is longer than 11 characters. 



If the first item is less than (or equal to) 1 1 characters, the ViC 
PRINTS It and then moves to the center of the screen to display 
the second item- if the first item is longer than 11 characters, 
the second item appears on the next line. Clear the screen, and 
try this example: 

PRINT "ABCDEFGHIJKL", "X" 
The screen will show: 



c 

c 



c 
c 
• 

c 
c 
c 
c 
c 




The first part of the message is 12 characters long, so the "X" 
ends up on the next line. Repeat this example with a semicolon 
(;} between the two items. 



22 






PRINT *'ABCDEFGHIJKL"; 'X' 
Does your screen show this result? 




Get the idea? The VIC acts like a typewriter with an automatic 
tab set near the screen's center. When it sees the connma, it 
either ''tabs" to the center of the screen or the beginning of the 
next line, whichever is next available. 

Clear the screen and type the following line into the VIC: 

PRINT 1,2 

The screen shows: 




Do you see the space in front of the first number? When the 
VIC displays numbers, it leaves a space at the beginning for the 
sign of the number. If the number is positive, you see a blank 
space. If the number is negative, a minus sign (-) would appear 
on the screen. 



23 



Try it and see. Enter this line into the VIC: 

PRINT -1,-2 
Look at the screen and see what is displayed. 




The numbers appear in the same places as in the previous 
example; they are preceded by the minus signs (-). 

These few examples give you some idea of how the VIC can 
help you get your messages and information on the screen. The 
VIC has many other ways to assist you with this task, and you 
will learn what they are as you continue to use your new 
computer. 



The VIC Calculator 



The VIC can also be used as a 9 digit calculator The + and 
- sign are used just like in mathematics. The VIC multiplica- 
tion sign is the asterrsk (*) and the division sign is the slash 
(/). Type these calculations and check the results. See Appen- 
dices C and K for more information. 



PRINT 1 + 1 
PRINT3-2 
PRINT 5*2 
PRINT 6/3 



If you PRINT a calculation you 
should put it outside the quota- 
tion marks. Try these examples: 




PR!NT2*(4/2}| 
PRINT 5000/5 I 
PRINT 2/3 
PRINT 3+3 

VIC automatically^, 
I performs the 
calculation outside) 
the quotes and 
prints the result 



Thet sign 
** is used for^ 

exponents,, 
^This means] 
^ 3^ or 3x3x3 J 



1 PR/NP^2*(4/2)'^ 

1 PRINT^'THE ANSWER IS"2*(4/2) 



, VlCprintsl 
everything 
inside the quotes 



c 

c 

( 

c 

( 

c 

( 

( 

( 

c 

( 

c 

( 

( 

c 

( 

( 

c 

c 

i 

( 

c 

c 

c 

( 

c 
c 
c 
c 
c 
• 



( 
( 
c 
( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
c 
( 
( 
( 
( 
( 
( 
c 



INTRODUCTION 
TO COLOR 

The VIC can print letters, numbers and graphic symbols in 8 
different colors. It can also print characters in reverse. 

With the screen clear, hold down the CTRL key and press this 
key: 



f 



Now let go of the CTRL key and put your finger on the SPACE 
bar at the bottom on the keyboard. Hold the SPACE bar down. 
What happens? Is there a blue line being drawn across the 
screen? 




Hold the SPACE bar down as long as you want. As the cursor 
disappears off the right edge of the screen, it reappears on the 
left and the blue line starts forming a larger blue color bar. 



Release the SPACE bar and do this: 



Hold down the CTRL key and press the RED key 



The cursor should now be red Press and hold the SPACE bar 
once again. Does a new red color bar start to form? Yes! Well, 
keep painting! 




25 




Change to other colors as you feel like it. Make the color bars 
as thick or thin as you like. Enjoy this newly discovered ability 
of the VIC that puts a little color into your life. 





Now, type liTTiTl £)^7 and hit the space bar. 
Nothing happens except blank spaces. Type 



and the color bar reappears. Try typing some letters 

in "reverse". Reverse letters make excellent headlines and are 

often used to highlight special words and numbers. You can 

also use reverse characters inside a program. For example, try 

this: 

NEW 



Bmf 



VIC20"; 



10 PRINT '■ 
20 GOTO 10 
RUN 



To get ready for the next chapter, type 

B^^M and type the word NEW and 




From now on, use 
this method to 
erase unwanted 
programs and 
start "NEW" 



( 
( 

c 

( 
c 

m 

o 

o 

c 

c 

m 

m 

t^ 

c 

# 



26 




Programming in 
Color 

The VIC Color Keys 

Changing Screen 
and Border Colors 

Screen and Border 
Color Combinations 

Coloring the Screen 

Screen Locations 

Random Colors 

Combining Sound 
and Color 

Keyboard Graphics 

Graphics in 
Headlines and Titles 



Try typing this program: 

Type this program exactly as shown and see 
what happens! 




To stop the program, press the jM key 




28 



C 
C 
C 

c 
c 
c 
c 
c 
c 
c 
c 
c 
c 
c 
( 
c 
( 
( 
( 
c 
c 
c 
c 
c 
c 
c 
c 
c 
c 
c 
c 
c 
c 
c 



COLOR & GRAPHICS 



The VIC and your color TV set give you the ability to put 
colors everywhere on the screen. When you first turn on the 
ViC, the border, the cursor, and any characters on the 
screen are aiready in color. But that's only the beginning. 
The VIC can display 8 cursor colors, 8 border colors and 16 
screen colorsl 

Let's start by using the f<eys on the VIC'S (keyboard to make 
colors on the screen. Type any letter. The letter should 
appear in darf( blue on a white screen. Now lool^ at the top 
row of keys (the numbered keys from 1 to 8). Do you see 
the color names written on the front of each key? Now find 



the key marked ^^ on the left side of the keyboard. 
Hold down the BM key and hit the key marked , 



Release the ^^ and *ill keys and type any letter 

on the keyboard. This letter should appear in yellow. Now 

hold down the BHI key and hit another color, then type 



some letters. See how easy it is to change letter colors on 
the screen? , 



Now find the key marked slw. Hold down the MM key 
and hit thelEm, Try typing some letters. All the letters 
you type (until you hit the ^^^^^H key) appear in 
reverse on the screen, like a photographic negative. If you 
hold down ^Q and hit l3a , the letters you type will be 

displayed normally. 



29 



PROGRAMMING IN COLOR 

Now let's combine color control with a simple program 
command. Note that when you type ^ffl and a coior key 



inside quotation marks, a reverse graphic symbol appears. 
This is okay. Do this: 



Hold down the 



key and press the [>f}fflj key 



Type the letters: 



NJ [EJ [WJ and press the 



key. 



Then type: [T] H] [J] [n] S Q 




and press 



Type: [2 



[g][o]s[o] msM m 



and press 



30 



# 
C 

c 
( 
c 
c 
c 

9 

c 
c 
( 
c 

c 

c 
t 
( 
( 
( 
( 
( 
c 
c 
( 
( 
c 
( 
( 
( 
c 
( 
( 
( 



If you have trouble typing this exampie, fiip back to the 
section called '"Getting Started" In Chapter One, You can't 
hurt the VIC with anything you type, but you can get 
confused by ceriain key combinations. If you accidentally 



leave the ffjf^ key engaged, for example, the resulting 
display is difficult to decipher. If you make a mistake, hit 

a few times and retype the entire line. The 



new line will automatically replace the old one. When you 
have the two lines shown above on the screen, type: 



RUN and press 



As soon as you press that final 



, you should 



see hundreds of red and blue balls float by on your screen. 
How? It's easy with the VIC. Look back at the example 
above. See the two strange characters in the line that begins 



with "1"? They were created when you held the ^g key 

and pressed the j^^ and mmk keys. The symbols that 

appear are VIC's shorthand to tell it to make the first ball red 
and the second one blue. 




and press 



31 



Nothing to it. When you are tired of red and bfue, press 
STOP, if you iike free form expioring, try retyping line 1. 



Throw in some 



and color keys aiong with graphics 



characters and ietters or numbers. The ViC can handie it ali 
and wiii give you an eniightening color display. 






THE VIC COLOR KEYS 

In the iast exampie, you discovered that you can insert color 
controls into a PRINT message by using the ^ffl and the 
keys whose faces are labeled; 



These keys are the number keys 1 through 8. When you 
press these keys in the middie of a PRiNT statement, a set 
of "strange" characters appear. To see what these 



characters look iike, press M^ (if the program is stiii 
running), ciear the screen, and enter: 

PRINT 



E]B[R]li[A]|][I]G[H][|[ill[o]B[w|Ea 

/ / / ///^y 

^Q ^^^ ^^ Q^ ^^1 jJESI ^A MBk 



Don't forget to put in the quotation marks or to use the 
key with ihs color keys. Your screen shouid show: 



32 



PRINT 



[R] G E S [S B S J H 



El[s] 




Where is the letter "A"? Ohf The second color key is 

and the background is . . . you guessed It . . . white. 
PRINTing a white letter "A" on a white background gives 
you a space in your RAINBOWS. 

The other seven letters in the word RAINBOWS are each a 
different color. The last letter, S, is yellow. Note that the 
READY message is also in yellow, along with the cursor. 
When color controls are put in PRINT messages, the VIC 
remembers the last color used and stays in that color. 

To change the cursor back to the regular blue color, hold 

down ^ffl and press ^^i . If you wish, try PRINTing 

some color messages on your own. You will get a chance to 
see more uses for the color control keys in just a bit. Right 
now, there is an important announcement . . , 



EXTRA!! EXTRA!! 

The VIC CoEor Show is on The Way!! 



33 



CHANGING SCREEN & BORDER COLORS 



Now that you know how to change the colors of letters and 
graphics, we're going to show you how to change the screen 
and border colors. You can display 255 different screen and 
border color combinations. To make sure the VIC is ready for 



what comes next, press |il|iJ and then 

erase the screen. Next, type these lines into the ViC 



and press 



to 



NJ EJ [W 



(Press 
following lines.) 



at the end of each of the 




1F0R X = 1 TO 255 
2P0KE 36879, X 
3PRINT " 




POKE 36879." X 



4F0R T = 1 TO 1000: NEXTT 



5NEXTX 




34 



c 
c 
c 
( 
c 

c 
c 
( 
( 
c 
c 
c 
c 
( 
c 
( 
( 
( 
( 
c 
( 
c 
c 
(> 
c 
1 
c 
( 
(. 
( 
( 
( 
c 



When you have typed these ffnes, look them over and see if 
they match what is sliown on this page. If there are some that 
don't match, retype those lines from the beginning. Use 



the 



to move back to any lines you want to retype. 



Once you are satisfied that the lines are all right, get a piece 
of paper and a pen or pencil and place it nearby. Then type: 



m lyy [Nj and press 



Your screen should begin to blush and flash. The border 
changes colors. The background changes colors. Even the 
small message at the top of the screen is changing colors. 
The VIC is displaying 255 different color combinations. 
(Syntax error in one of the lines? Retype that line and 
then type: 



m 



U N 



and 



again.) 



While the VIC is running, if you notice a particuiar set of 
colors that look interesting; write down the number of that 
combination. Only the number at the end of the printed 
message is changing. The ''POKE 36879," stays the same. 
(Occasionally, you will not be able to read the message 
because it is the same color as the background. C'est la vie. 
The letters and numbers will reappear after a lew additional 
flashes,) The VIC has eight border colors, sixteen 
background colors, and eight character colors. You can put 
characters in all eight colors over any background. That 
gives you a lot of combinations to explore. 

If you want to restore the screen to Its original colors, simply 
hold down the ^M key and hit 



Line two in the example above is responsible for making the 
VIC change colors. The line contains a POKE command. 
Every POKE command has two numeric values that the 
VIC uses: 




35 



The first number (in this case, 36879) is the location in 
memory (think of it as a Httie box labeled 36879) into which 
you are going to POKE (ie. place) the second number. X. The 
memory location 36879 happens to be where the VIC stores 
Its information on what the screen's border and background 
colors should be. Each value of ''X" corresponds to a 
different color combination the VIC can display. For this 
example, "X'* starts with the value 1, then changes to 2, 3, 
and so forth, up to a final value of 255, 



1] 


/ 


1 




/ 


Memory 

Location # 

36877 


/ 



Memory 

Location # 

36878 





Memory 

Location # 

36879 



AN EXAMPLE OF POKE 36879, 8 



To assist you in your quest for the perfecf color 
combinations, here is a tabie of POKE values ("X" values) 
and the background and border colors they produce. The 
tabie gives you the POKE values to produce all combinations 
of these colors. The POKE values are in sequence with sl<ips 
of eight (8) numbers. The missing numbers are the POKE 
values that cause the reversal of displayed characters. 



36 



( 

c 
c 
( 
( 
( 
( 
( 
( 
( 
c 
( 
( 
c 
c 

( 
( 
( 

c 
( 
c 
( 
c 

c 
( 
( 
c 

c 
( 
( 
t 



SCREEN & BORDER COLOR COMBINATIONS 











Border 










BLK 


WHT 


RED 


CYAN 


PUR 


GRN 


BLU 


YEL 


Screen 


















BLACK 


8 


9 


10 


11 


12 


13 


14 


15 


WHITE ' 


24 


25 


26 


27 


28 


29 


30 


31 


RED 


40 


41 


42 


43 


44 


45 


46 


47 


CYAN 


56 


57 


58 


59 


60 


61 


62 


63 


PURPLE 


72 


73 


74 


75 


76 


77 


78 


79 


GREEN 


88 


89 


90 


91 


92 


93 


94 


95 


BLUE 


104 


105 


106 


107 


108 


109 


110 


111 


YELLOW 


120 


121 


122 


123 


124 


125 


126 


127 


ORANGE 


136 


137 


138 


139 


140 


141 


142 


143 


LT. ORANGE 


152 


153 


154 


155 


156 


157 


158 


159 


PINK 


168 


169 


170 


171 


172 


173 


174 


175 


LT. CYAN 


184 


185 


186 


187 


188 


189 


190 


191 


LT. PURPLE 


200 


201 


202 


203 


204 


205 


206 


207 


LT. GREEN 


216 


217 


218 


219 


220 


221 


222 


223 


LT. BLUE 


232 


233 


234 


235 


236 


237 


238 


239 


LT. YELLOW 


248 


249 


250 


251 


252 


253 


254 


255 



COLORING THE SCREEN 



Time to combine the VlC's color and graphics features in a 
deiightfui color display. Again, you only have to enter a few 
lines into the VIC, and spectacular events begin to happen. 

If any examples are still flapping or bouncing across the 
screen, ^3 them. Clear the screen. Then, type these 
mysterious lines: 



Isj E W 



(not too mysterious^ yet) 



37 



1 L = INT(RND(1)*500) 4- 1 



2 C = INT{RND(1)*8) + 1 




3 POKE 7680 +U 160 





4 POKE 38400 + L, 




5 GOTO 1 



Check the example to see if all the lines were typed as 
shown. If they are all right, clear the screen and type 



Your screen should explode in tiny bursts 



RUN 



of color. 



The VIC has done it again! With only a few keystrokes, it fs 
now dabbling color everywhere. How is this being done? 



# 

c 

c 

c 

( 

( 

c 

c 

c 

( 

( 

c 

( 

( 

c 

( 

( 

( 

( 

( 

c 

c 

( 

c 



In simple terms, lines 1 and 2 are randomly selecting where 
on the screen the color will go (L for Location maybe) and 
what color (C for, of course, Color). Line 1 generates a 
number from 1 through 500. Line 2 generates a number from 
1 through 8. 

38 



( 
• 




Line 3 POKEs a character onto the screen. 
The value 7608 represents the home position 
on the screen; the top lefthand corner. 
The POKE value 160 is a solid block 
(essentially a reversed space)* 

Line 4 POKES the color onto the character. The vaiue 38400 
represents the location in memory of the color component of 
the character in the home position. 



SCREEN LOCATIONS 



VIC TIP: 

To POKE characters on the screen, you must POKE the screen 
location and the color at that location for each character. The screen 
locations start at 7600, The color locations begin at 38400. See 
Appendix for the screen memory map. 



You Should try POKEing other values onto the screen. 
Change the 160 in line 3 to any number from to 255. 

EXPERIMENT^ and enjoy your VIC*s colorful personality. 



There are 506 possible screen locations (chart). You can 
place any word, letter, sentence, graphic, or whatever — 
whenever you want on the screen. Just imagine the screen 
consists of 506 boxes like this — each box has a number. 



Enough POKEing around! Time to get back to the color 
control keys. 

39 



VIC TIP: 

To restore your VIC to its normal border and background colors 
type this POKE statement: 

POKE 36879,27 
or hold down the RUN/STOP key and hit 




RANDOM COLORS 

You are now going to find out how you can fet the VIC 
choose coiors to put on the screen. First clear the screen, 

and type these tines (press ^^^^^H after each line): 



1 PRINT " 




2 GOTO 1 



RUN 



( 
( 

c 
( 
{ 
( 
c 
c 

c 
c 

c 

c 
c 
c 
c 
c 
( 
c 
c 
c 
c 
c 



Your screen should fill with red and blue birds. Wonder 
where they are flying to? They are really moving. 




40 



Let the birds fly for a while. When you want to stop their 
flight, press Q . 



Now that you know how to create birds, clear the screen and 
type these lines: (Remember the ^^^^^H ) 



[n][1[1 

1 A$ = -aiiElB[inBD 



2 N = INT(RND(1)*8) + 1 ^ 




4 PRINT B$ " ^-•-' r»> 




5 GOTO 2 

Look the lines over once they are entered. Checl< to see if 
they match what is shown above. When you are ready, clear 

41 



the screen and type [r] [u] El - '^ V*^^ ^^^® ^^y errors, 



retype this problem line and [rJ |_U| [n] it again, Sam 



(excuse us, VICII). Birds! Birds! EverywIiereU In every color 
of tine rainbow! Your screen sliouid be humming (oopsl) with 
flocks of 'Yafnbow" birds- Notice that there are gaps in your 
flock. Actually, the VIC is PRlNTing white birds in those 
places. If you want these 'Invisible" birds to appear, you 
must change the background color. (Remember how? You 
POKE a number into locatton 36879.) 

Of course, if you change the background to another color, 
say blue, then all the blue birds will disappear. Try it and see 

for yourself. Press W^ when you want to keep the birds 
from flying. ™" 



The last example used some interesting VIC features to get 
the birds on the screen and change their colors. Let*s look 
at the example line-by-line. The first fine is: 



1 A$ 



■ BElBaDSIIl 



The color controls form a long string of characters and 
are put into the VlC's memory in a place called AS 
(pronounced "A string" or "A dollar sign"). You can think of 
A$ as being like a box where strings of characters can be 

stored. The first position in the box A$ contains thej 

control character. The fast position contains the ^ 

control character. 



^^/jhbO 





B 



42 



C 

( 

c 
c 
( 
c 
( 
c 
c 
( 
( 
c 
r 
( 

c 
( 
( 

( 
( 



c 
( 

c 

t 

c 

c 
c 

• 

c 



The next line is: 

2 N - INT(RND(1)*8)+ 1 



This line generates a random positive whole number from 
one through eight and puts the number into ''H'\ ^*N" is the 
place in the VIC's memory that can be used to store 
numbers. The VIC knows that "^N" is a place to store 
numbers since there is no dollar sign {$) at the end of 
the name. 

In line one, the location used to store the color controls was 
called A$, and it has a dollar sign on the end. The ViC knows 
that locations whose names end with a dollar sign are to be 
used to store messages or strings of characters. 



For more information on how [T] [n] [T] and [r] \n\ \d\ work 

together to generate random numbers, look at Chapter 
Seven in this book. For now. just be aware that this line is 
producing numbers from one through eight. See the number 
eight on the right side of the equal sign? That number 
controls how many random numbers are being generated. If 
you were to change the eight to a six, then any number from 
one through six would be produced, 

Hmmm . , . moving right along now: 

■m 

3 B$ = MID$(A$,N,1) 



This line creates a new box called B$, and puts one color 
control character into it. A$ contains all eight color control 
characters- "N" is a random number from one through 
eight. What does MID$ do? It picks out one color control 
character from AS at the '^N"th position in the string. This 
character Is put into B$. Yes, ^'Virginia", now we have three 
little boxes inside the VIC, one called A$, one called "N" 
and one called B$. Each time the VIC gets to line two, it is 
given a new value for ''N". This determines which color MID$ 
picks and puts into B$. 



A$=BQ5K[]QBD 



43 



The fourth line is: 



4 PRINT B$ "\.«-y f-m^ '•■ 



This line tells the VIC to use the color it finds in the BS box 
and to draw the birdlike creatures with it. The command, 
PRINT 8$, creates the same effect as typing a specific color 
control character. By using B$, however, we can have the 
VIC change the color character automatically. As "N" (line 2) 
changes, B$ changes (line 3), and the birds change color 



( 

( 

c 
c 
c 
c 

• 

c 

c 




\^ 



.\ 






'(r 



The VIC^s abflity to generate random numbers can be 
combmed with its color, sound, and graphics features in 
many interesting ways. For example, let^s revisit the VIC 
Color Show, but randomly, and make some noise while we 
are at it. 




44 



t 



In this last example, the VIC's color and sound are 
both randomly produced. Enter the following lines into 
the computer: 



NEW 

1P0KE 36878, 3 



2C = INTtRND{1)*255) + 1 



3S ^ INT(RND(1)*50) + 175 




4P0KE 36879, C 



5P0KE 36875, S ^ > p|ay note. ) 

6F0R T = 1 TO 100: NEXT T ^ C Wait. ) 

7G0T0 2 



The bubble captions tell most of the story on this example. 
Chapter Five tells you more about music. If you are ready to 



run the example, clear the screen and type |_Rj (Jjj [Nj , then 
press 



45 



\ 




/ / / 



My, myll What a wild bunch of sound and color 
combinations. Oh, well! You get what you play. You can't 
expect random music to be to everyone's taste. 

When you want to halt this color and sound machine, press 
.j,j . Then you need to type these two lines to shut off the 

note that is still playing and restore the VIC screen to its 
normal colors: 



POKE 36875, 



POKE 36879, 27 



r Stop T 
< \y note, J 




Time for you to explore on your own. Experiment witli tlie 
VIC'S colors. Enjoy your colorful, musical VIC computer. 



46 



• ' 

( 

( 

( 

( 

( 

( 

«' 

( 

( 

( 

( 

( 

( 

{ 

( 

( 

( 

( 

( 

( 

( 

( 

( 

( 

( 

( 

( 

( 

( 

( 

( 

( 

c 



KEYBOARD GRAPHICS 



One of the special features of your VIC 20 is the graphics 
keyset. Most of the keys have two graphic characters printed 
on the front. You can display these graphics on the screen, 
Of, if you have a Comnnodore dot matrix printer, print them 
on paper along with all the other keyboard symbols. 

To display the graphic on the left side of the key, hold down 
the Comnnodore key while pressing the graphic key, to 



display the right side graphic, hold down the 
type the graphic you want. 



key and 



VIC TIP: 

Caution... if you push both the SHIFT and Commodore Keys at the 
same time, you will switch to upper/lower case mode. In upper/lower 
case, ofiiy the left side graphics are available. To get back to upper 

case/graphics mode, push ^^^| and Q together. 



The easiest way to use VIC graphics is to type the 
COMMODORE H or BMB key, and the graphic symbol 



you want to display from the keyboard. For example, type 
the following: 



You should see a blue /learf printed on your screen. Try 
typing some other graphic keys. Here are some other keys 
you might want to try: 



47 




Left Side G 


raphics 


Right Side Graphics 


s 


't 


^^^^|, |Q 


s 


f@l 


^^^H W 


o 


+ 


^^^fl M 


s 


B 


^^^^1 



Notice that the left side graphics are good for creating 
charts, graplis and business forms. Right side graphics 
are good for drawing illustrations, animations . . . even 
playing cards! 



GRAPHICS IN HEADLINES & TITLES 



c 
c 
c 
c 
c 
c 
o 
c 
c 



Graphics aren't limited to cartoons and games. You can use 
a variety of special effects to enhance titles in charts and 
graphs, or highlight special words in programs that use a lot 
of text. The easiest way to highlight a word or phrase is to 



type It in REVERSE. Simply type 
word you want. 

For example: 



[n E [E m E a 



, and the 



[1 HI [E lU E B 




EEH 



Type a 
headline using, 
the keyboard. 



48 



Now try some spaces to create a title bar 

[1E11B11S0 



□ 




am E E E [D [n] E 



RUN 




Another way to highligtit a word is to draw a graphic box 
around it. The technique is like drawing. Be sure to type 
exactly as shown. Let's do it step by step. 



dS [E m [i [i]"H lil H [1 H [il H y H 



R U lN 




The screen will show a straight line. The next line includes 
your headline and a vertical line at each end to complete the 
sides of your "box". 



11 m E S B 




H[g] [a][b][c] 3 



[r][u]{n] 



See how we are buflding the headline box? Now to finish . 



L 5 times! '\ 



aSHSE 



R LI L N 



VIC TIP: 

To edit your program, type LIST and press RETURN. Now you can 
go back and ctiange a line that isn't exactly right, by using the CRSR 
and INST/DEL keys to move ttie error and retype it. After you make 
a correction or change, press RETURN to er>ter the change for that 
line . . . or . . . you can also retype any line any time and press 
RETURN to ctiange it. 



O 

o 
o 
c 

c 



Here's another way to highlight a word or headline, by 
animating it so it appears to blink several times when it 
comes on the television screen . . . 



N E m 



10 FOR H = 1 to 250 



20PRINT " 




IfHiCiEEEHES]" 



c 
( 
( 
( 
c 
c 



25FORT = 1 TO 50; NEXT 



30PRINT ■' 



H][I][a][d][l][T]0[I 



35FOR T = 1 TO 50: NEXT 



c 

c 
c 



40NEXT H 



R U IN 



If the headline doesn't overlap evenly, try adjusting ttie 
spacing inside the quote marl<s. To speed up or slow down 
the blinking change the number fn lines 25 and 35. 



50 



c 
( 
c 
c 
( 
c 

S 



Try typing this program: 

Type this program exactly as shown and see 

what happens! 



10 PRINT" 

20 PRINT " 15 O (71 " 

30 PRINT " □ ^ CH " 
40 PRINT " □ S " 
50 FORT = 1TO300:NEXT 
60 PRINT " H ": 



80 PRINT " ^ S " 
90 PRINT "□[][]" 

100 FOR T==1 TO 300: NEXT 

110 GOTO 10 



To stop th e pro gram, 
press the ^9 key. 




52 



C 
C 
C 
( 
C 
C 
C 

c 
c 
c 
c 
c 
( 
c 
( 
( 
c 
c 
c 
( 
( 
( 
( 
c 
( 
( 
( 
( 
( 
( 

( 
( 
( 



FLYING BIRDS 



This Chapter shows you how to use the VIC'S graphic abilities 
to create illusions of characters moving about the screen. 

The illusion of movement you can create with the VIC Is often 
referred to as animation. Animation can make any program — 
from games to business programs — fun and exciting. 



Let's begin by entering the following lines: 
Hold down the B!^^| key and press the 



El [e] |wl and press the 



key. 



key. 

p] S DH B E S 




i^ 








To get birds 




HOLD 


PRESS 


v#y ^^^^ 


J ^ K 


^#'^ ^^^1 


U Q 1 


For more on ' 


BIRDS" see 


Chapter 3, ' 


Graohics" 



and press 

2\ ^^^ [E [o] [E ^^3 \f] El 
a SSH^ EHl] [1 E H m 

and press ■■ . 

PRI NT"gr•■^ Q 



and press 

[4] ^B mmM E3I ^^ 




and press 




\G\\g\[j]\o\ 



m 



53 



WHAT YOU HAVE JUST TYPED 
SHOULD LOOK LIKE this: 



1 


PRINT " 


V ^^ 




2 


FORT = 


: 1 TO 150: 


NEXTT 


3 


PRINT" 


V r**% ' 




4 


FORT = 


= 1 TO 150: 


NEXTT 


5 


G0T01 







Look over what you have typed. Does it match what is shown? 
If it does not, re-enter the lines that are different. When 
everything matches, type: 

[r] [U] [n] and press 



HINT: 



You can re-enter or change any line by typing it over. The 
second typing will automatically erase and replace the 
first. You can erase a line by typing the line no. only 

followed by 



Befiold your first VIC illusion or animation. The "bird" creature 
is huffing and puffing up in the top left-hand corner of the 
screen. It seems to be using a lot of wing power, but there must 
be a strong headwind. The bird is getting nowhere. 




You, however, are getting places. Can you see how the bird 
appears to be actually moving its wings? Study the example for 
a moment. The secret to almost all animation on the VIC is 
given in this one example. How you can create this illusion of 
movement is easily described in a few simple steps. Here is a 
brief summary of how to make just about any character wink, 
blink, wave, nod, seem to move, and so forth. 

54 



( 
( 
( 
( 

c 

# 

( 

( 

( 

( 

c 

( 

( 

< 

( 

( 

( 

( 

c 

( 

( 

( 

( 

c 

( 

( 
( 

( 
( 
( 
( 
( 



( 
( 

( 
( 

( 
( 
( 

( 
( 
{ 
( 
( 
c 
( 
( 
( 
( 
( 
( 
< 
{ 
( 
( 
t 
( 
( 
i 
i 
( 
( 

( 
( 
c 



First, display the character or combination of characters in one 
position on the screen. 



f First L 




Second, wait for a short period of time. A FOR-NEXT "time 
delay loop' makes this happen. Examples of '^time delay" 
instructions are shown in lines 2 and 4 of the flying bird 
program. These lines tell the VIC to count from 1 to 150. The 
VIC can count to 150 quickly. Try changing 150 to 500 (or some 
other number) and see what happens. 

Third, display the character again but with some part of it 
altered. Because of the previous delay, your eye is fooled and 
you think you have seen 
"movement". 




Fourth, wait again. Based on what effect you are trying to 
achieve, this wait may be longer or shorter than the first delay 
loop, in the example, the delays between PRINTings were the 
same. 

Fiftfi (the easy part), repeat the first four steps just mentioned. 
This is accomplished by the GOTO command which tells the 
VIC to go back to the first line and start over again. Thus, the 
program prints the bird with his wings "up'\ counts to 150, then 
prints the bird with his wings "down" and goes back to the 
beginning again. 

In the first and third steps, where the character is being 
displayed, it is often necessary to make sure that no old 
character parts are left on the screen. In our bird example, this 
problem is taken care of by putting the screen clear character 

in each message. That character 



and 



clears the screen and homes the cursor so each version of the 
bird {wings up, wings down) appears in the upper left-hand 
corner. 

55 



You may wan! to experiment with this example some. 
Press PS) to stop the wing flappings and change the upper 



counting limit (150) in lines 2 and 4. Try changing just one 
value, leaving the other at 150. Does your bird begin to soar? 
Try a value like 50 in both places. Does your bird fly faster? 
What about an upper limit of 500? 1000? 



Hmmm...lhe bird gets rather s4-o-w. 




CLeaROut for HOME 



You already know that you can clear the screen by holding 
down B^^l and pressing the GEI key. From within 



a program, you can tell the VIC to clear the screen. You do so 
by typing: 



PRINT 



"@"= 



This character appears 
when you hold 
and press 



When you are entering a PRINT message, if you press the two 
l<eys ( Hi^l and IPJI)! ) that you use to clear the 



screen, the reverse heart image appears on in the message 
field. That symbol is a signal to the VIC that when the message 
is PRINTed, the screen Is to be cleared at that place in the 
message, and the cursor sent home. Home is the upper left- 
hand corner of the screen. 




56 



C 
C 
C 

G 
C 



c 
c 

c 

•• 

c 

c 

c 

( 



c 

C' 

( 
( 
( 
( 
c: 

( 



Try the PRINT statement directly. Type it into the VfC. Does the 
screen clear? 

( Yes" 

Type: PRINT ^- 1^1"; < V Works in the 

immediate mode 



Now, mess up the screen. Put some birds, characters, numbers^ 
and graphics symbols all over the place. When your screen is 
sufficiently full, type this line; 

PRINT ^' [S] "; 




Did you notice a difference from before with the other PRINT 
statement? Yes, thfs time the cursor went ho me but the screen 

did not clear. If you don't press the ^^^| key while typing 

into the message field, the reverse S image appears 



instead of the heart. The reverse S tells the VIC to home the 
cursor, but do not erase the screen. 




# 




BOUNCING BALL 

Clear t he screen and enter the following into the VIC: 
(Press ^^^^^1 after typing each line.) 

NEW 
1 PRINT" 




2 GOTO 1 

RUN 

When RUN is typed, the screen should fill with coiumns of blue 
balls. Let the balls flow by for awhile and then press 



Pressing 



causes the BREAK and READY messages 



to appear. Now, type; 

1 PRINT ";t [R] • H ' 





The two reverse image characters are the symbols the VIC puts 
in a message field when you hold down ^H ^^^ press 



the 



£» and ^ 



keys. 








After you have typed the new line, tell the VIC to RUN this 

example: 

Type: RUN 

What happened to the balls? Press the ^Q key to slow 

down the PRINTing. There are now columns of blue rectangles 
with white holes in them. Can you guess why? 

58 



c 
c 
c 
c 
c 
c 
c 
c 

c 
( 

( 
c 
( 
c 
c 
( 
c 
c 
c 
< 
c 
c 
c 
( 




Putting the RVS ON control character in front of the ball 

symbol, causes the VIC to reverse the colors being used to 
display each ball. The ball is normally blue and is surrounded 
by whrte background. The reversal made the background blue 
and the bail white. 




Placing the RVS OFF control character after the ball, tells 

the VIC to reset the reversing of background and character 
colors. That is like reversing the reverse, and you end up back 
where you started. If the RVS OFF is not used, an 
interesting effect is produced. 

the reverse balls if need be. and enter this fine: 




1 PRINT " 



Type: RUN 



When RVS OFF is not used, all the spaces on the screen 

are reversed and become solid blocks. What an interesting 
pattern maker the VIC can become. How about designing your 
own textiles, or wailpaper, or floor tiles with the VIC? What can 
you think to do with the VIC? 

59 



THE CURSOR KEYS 

The four cursor control keys let you move the cursor anywhere 
on the screen. You can put the cursor controls in PRINT 
statement message fields to help you position the characters 
and messages you are printing. Here is the bird example from 
the beginning of the chapter with the addition of a few cursor 
controls. 

Clear the screen, and enter this new bird display: 



NEW 

1 PRINT '^ um^^^mmcD^': 





This line uses several cursor controls ( DOWN , RIGHT , 
LEFT ) to animate and move the bird image. You will see the 
movements when you RUN the entire example, 

2F0RT = 1 TO150:NEXTT< — } Wait^ 

SPRINT" r»^ CDCDDD "; 

This line contains three LEFT cursor control characters. 
4F0RT = 1 TO 150: NEXT T 

5 PRINT ".^^ [DCDQ] "; ^ Ef3ses bird 

( 3 spaces -L /" 

6 FOR T = 1 TO 150: NEXT T ^l_(j/Vait again j 

7 GOTO 1 ^-A^A.^^ 



60 





( 

<> 

c 

• 

M 

< 
( 
( 
C 
( 
( 
( 
( 
( 

c 
( 
( 
( 
( 
( 
( 
c 
( 
c 
( 
( 
( 
c 



Type and check the example against the printed text. When you 
are ready, type RUN and watch the birdie. 





The cursor control characters in this example moves the bird 
down and across the screen. Easy as bluebird pie! 

Your turn again; why don't you invent another creature and 
m-o-v-e it across the screen. 



ANIMATING WITH 
POKES AND PEEKS 

So far you have learned to use the PRINT statement with the 
cursor controls and the color controls to move objects around 
the screen. This is probably the fastest way to move objects 
using BASIC, but it is not the smartest. Most arcade-style 
games require that the object moving around the screen reacts 
to other objects on the screen. The only practical way to 
program this is using the PEEK and POKE statements. 

In order to use this technique, you must first understand the 
concept of memory-mapped video. Each position on the screen 
corresponds to a location inside the ViC's memory (RAM). 
Since there are 506 possible positions on the screen for 
characters, there are 506 locations in memory to hold the 
characters. And, since each location in memory can contain a 
number from to 255, there are 256 possible values for each 
memory location. These are the 256 different characters that 
the VIC can make {see Appendix H). A number in a position in 
screen memory is a code for the character in that position. 

Screen memory in the VIC normally begins at location 7680, 
and ends at location 8185, Location 7680 is the location of the 
upper left corner of the screen. Location 7681 is the position of 
the next character to the right of that one, and so on down the 
row. The next location following the last character of d row is 
the first character of the next row down, 

61 



m 
( 

Now let's say that we are controlling a ball bouncing on the / 
screen. The ball is in the middle of the screen, column ten and 

row ten. (The upper left corner is column zero, row zero.) The C 

lormula for calculating the memory location on the screen is: ^ 

P-7680 + X + 22*Y ^ 

where X is the row and Y is the column. Therefore, the memory C 

position of the bail is 7680 + 10 + 220, or 7910. Clear the screen 
and type: 



POKE 36879,8 

This changes the color of the screen to all black. Now type: 



POKE 7910,81 (^ 



A ball appears rn the middle of the screen! You have placed the C 

character directly into screen memory without using the PRINT 
statement. 



( 

The ball that appeared was white. However, there is a way to 

change the color of an object at any location on the screen, ( 

also using POKEs. Type: r 

POKE 38630,3 ( 

The balTs color changes to cyan. For every spot on the VlG*s v 

screen there are two memory locations, one for the character r 

code and the other for the color code. The color memory map 

begins at location 38400 (top left-hand corner), and continues ( 

on for 506 locations. The color codes from to 7 wHI give you 

the 8 colors numbered 1 to 8 on the keyboard. (Other numbers 

will give strange-fooking results. See the VIC Programmer's f 

Reference Guide for a complete explanation.) 



c 



62 



# 
( 

c 

#' 

c 
( 
c 



SCREEN MEMORY MAPS 



This is 

location 

7681 



.This is 
memory 
location 
7680 

.This one 
is number 
.7702 

Location - 
7910 
(a ball) 




CHARACTER CODES 







































, 




























































































































































































































































































































































































































- 


LJ 




— ^ 


81 




























^ 




































1^ 


^ 




































































































































































































































































































































































































































































































Location 
* number 
'8185 



This Is k 


\ 












( 


::OLOR CODES 














<i 














































memory ] 














































location 














































38400 J . 














































-\j^>^ 










































v-/>*»^ 








































1 






























































































38630 1 












































(cyan) J 












Q 


















































^ 


3 




























































































































































1 






































( 
















































; 
































































































/"V V~>i 














































1 














































Location j 






















i 


I 






i 












38884 jT 














































-lj^J"^ 




















\ 

























63 



Here is a short program to bounce a ball around the screen, 
followed by a detailed explanation. 



10 PRINT" ^gjg igg - 




20 POKE 36879,9 




30 POKE 36878.15 




40 X = 1 




50 Y = 1 




60 DX-1 




70 DY = 1 




80 POKE 7680 + X + 22*Y, 81 




90 F0RT = 1 TO 10: NEXT 




100 POKE 7680 + X + 22 *Y, 32 




110 X-X + DX 




120 IFX-0ORX = 21 THEN DX = 


-DX: POKE 36876. 220 


130 Y = Y + DY 




140 1FY = OORY = 22THEN DY- 


-DY: POKE 36786, 230 


150 POKE 36876, 




160 GOTO 80 





Line 10 clears the screen, and line 20 sets the color of the 
screen to black with a white border. Line 30 sets the loudness 
of the sound generators to the loudest leveL 

The X and Y variables used in lines 40 and 50 keep track of the 
current column and row position of the balL The DX and DY 
used in lines 60 and 70 are the horizontal and vertical direction 
of the ball's movement. When a + 1 is added to the X value, the 
column is moved 1 to the right. When -1 is added to X, the 
column of the ball is moved 1 to the left. + 1 added to Y moves 
the ball down a row, and -1 added to Y moves the ball up a row. 

Line 80 puts the ball character on the screen at its current ( 

position. Line 90 is a delay loop, leaving the ball on the screen . 
just long enough for your eye to see it. LinelOOnow erases the 

ball by putting a space (code of 32) where it was on the screen. ( 

Line 110 adds the direction factor to X. Line 120 tests to see if C 

the ball has reached one of the side walls, reversing the ^ 
direction and beeping if there is a bounce. Lines 130 and 140 do 

the same for the top and bottonn walls. ( 

Line 150 turns off the sound, if any, to complete the bounce C 

sound effect. Line 160 sends the program back to display and ^ 

move the ball again. 

C 

C 



Play with thrs program a little. By changing the number in line 
80 from an 81 to another character code, you can change the 
ball to any other character. If you change either DX or DY to 0, 
the ball will bounce straight instead of diagonally. 

Now we can add a little more intelligence to this program. So 
far the only thing we check for is the X and Y values getting out 
of bounds for the screen. Add the following lines to the 
program shown above. (Just type these lines and they'll be 
added automatically) 

32 FOR L = 1TO10 

35 POKE 7680 + INT (RND (1) *506), 102 
37 NEXT 
155 IF PEEK (7680 + X + 22*Y) = 102 THEN DX = -DX: DY = -DY: 
POKE 36876, 180: GOTO 110 

Lines 32 to 37 put 10 gray characters on the screen in random 
positions. Line 155 checks {"PEEKs") to see if the ball is about 
to bounce into a grey block, and reverses the ball's direction if 
so. 

See Appendices H and I for more information on animation. 



as 



c 
c 
c 
c 

c 
c 

c 
c 
( 
c 
c 
c 
( 
( 
c 
c 
c 



Try typing this program: 

Type this program exactly as shown and see 
what happens! 



10 PRINT" 

20 FOR I = 1 TO 5 

30 POKE 36873+ 1,0 

40 NEXT I 

50 PRINT "WHICH VOICE (1-4)?" 

60 PRINT "IF DONE, ENTER 0" 

70 INPUT N 

80 IF N=0 THEN END 

90 PRINT "WHICH PITCH (12a-254)?'' 
100 INPUT P 
110 POKE 36878, 4 
120 POKE 36873 + N,P 
130 FOR J = 1 TO 2000: NEXT J 
140 GOTO 10 



To Stop the program, press the 




68 



C 
C 
C 
C 
C 
C 
C 

c 
c 
c 
c 
c 
c 
c 
c 
c 
( 
c 
c 
c 
c 
c 
c 
c 
c 
c 
c 
c 
c 
c 
c 
c 



MAKING MUSIC 



You may not realize it, but you and your VIC can make music 
and sound effects! This chapter introduces you to the music 
and sounds that the VIC can make. It will teach you how to 
control these sounds and play any kind of music from Bach — 
to Rock, So put your candelabra on your TV set, and get ready 
for a concert! 



First, let's find out how to play a note: 
Hold down the BMW key and press the 



key. 



[N] i] jWl and press the muHB key. 

EioiEi] mm [i[6i[i][z][8]n[3] 



and press 

EIoKKlll] 

and press 



C3![6][8l[E[I]ntIl[I][5] 



At this point, you should hear a tone coming from your TV 
speaker. If you don't, try adjusting the volume control on the TV 
in the normal way. Set it so that the tone is comfortably 
loud. ..like music on a TV show. 

You've just played middle C, one of 128 notes in VIC'S 
repertoire 1 To turn off the tone, type this: 

[p] [0] [K] [g ^^J [1 [6] HE End 

Next, let's find out how many notes the VIC can sing: 
TypeNEV\/ and press I 




Now, type this program: 

1 POKE 36878, 15 

2 FOR I = 128 TO 255 

3 POKE 36875, I 

4 FOR D-1 TO100 

5 NEXT D ^^HH ^^^^^^^^^H 

( 



6 NEXT I 

7 POKE 36875, 




70 



( 
( 

( 



Take a fittle time to lool< at ttie VIC's screen, and see if all ot 

the lines on it look just like these. If any line looks wrong, just ( 

type it over again. Make sure you include the line number. VIC 

will automatically substitute the new line for your previous 



( 



version. To get a Ifsting of the lines in your program, type: ( 

LIST and press ^^^^^ ( 

If all the lines are OK, type: ■ 

RUN and press ^^^^^| 

and you will hear all 128 notes that the VIC can sing with this / 

voice. (If you don't, recheck the lines as you typed thenn,) If you 

want to hear the notes again, type: ( 

RUN again, and press ^^^^^ . ( 

( 
Now that you have heard the notes that your VIC can make, we 

want to explain a little bit about how it does all that, ( 

Inside the VIC, the Video Interface Chip (which gives the VIC its ^ 

name) handles both sound and picture. It lets your VIC send ( 

sounds to the speaker of your TV set. The volume of sound can 

be adjusted by the volume control on the TV or from the VIC's ( 

keyboard. 



( 
C 
« 



THE FOUR VOICES OF VIC 

Your VIC has four voices... that isjt can '*sing'* four different 
notes to you at the same tinne! You might think of them as 
soprano, alto, tenor, and noise. Each of the voices has a 
particular "speaker control number". By using this number, we 
can turn the speaker '*on" and use it to create a musical note 
or sound effect. We use the word POKE to do this. 

The VIC'S four speaker numbers are: 

36874 {speaker 1 - music) 

36875 {speaker 2 - music) 

36876 (speaker 3 - music), and 

36877 (speaker 4 - noise). 

The volume control number is 36878. 






36874 , . , (alto) 



36875 . , . {tenor) 36876 . . . (soprano) 





36877 . . . { noise) 
speaker 1 



36878 . . . {volume) 



To play a note, type POKE and the speaker number, a comma, 
and a number representing the note you want to play. 



For example, type: 

POKE 36874, 128 and press 



71 



You've just sounded note #128 using speaker #36874, the first 
(lowest) voice. From now on, let's call this speaker SI {short for 
speaker 1); the second, S2; the third, S3; and the fourth, S4. 82 
stngs higher notes than 81 does, and S3 sings higher than S2. 
S4 sings with a buzz in its voice. ..this "voice" creates "white 
noise" used for sound effects. 

By the way, to turn off a voice, POKE into it, like this; 
POKE 36874, and press 



This might seem a little complicated if you're not a "computer 
musician" yet, so we've made it easier for you. You can save a 
lot of typing if you use the following short program to translate 
the speaker numbers into shorter numbers. 

Type this on your VIC exactly as shown: 

NEW 

51 = 36874 

52 = 36875 

53 = 36876 

54 = 36877 
V = 36878 



This allows us to refer to the speaker numbers by the 

abbreviations SI, S2, S3, S4, and V (volume). Before proceeding C 

check to make sure that each line has been entered correctly ^ 

Now you are ready to make sounds the easy way! '^' 

POKEV,10 ■jffli^ /_.. ^ (" 

C 

c 




72 



This POKES 10 into the location that controls volunne. The 
volunne control can store any value between and 15. The 
higher the number, the louder the volunne, 

POKE SI, 195 
POKE S2, 215 

POKE S3, 231 

Experiment a bit mXh this method of producing sounds. It's 
much easier, isn't it? When you want to stop the sound {to let 
your poor ears rest), POKE into the speakers you want to turn 
off, like this: 

POKE SI, 

POKE S2, 
POKE S3, 

Here is a chart of the values which can be POKEd into the 
speakers to get various notes: (Note: numbers below 128 produce 
''silence'*): 

TABLE OF MUSICAL NOTES 



NOTE 


VALUE 


NOTE 


VALUE 


C 


135 


G 


215 


G# 


143 


G# 


217 


D 


147 


A 


219 


D# 


151 


A# 


221 


E 


159 


B 


223 


F 


163 


C 


225 


F# 


167 


C# 


227 


G 


175 


D 


228 


G# 


179 


D# 


229 


A 


183 


E 


231 


A# 


187 


F 


232 


B 


191 


F# 


233 


C 


195 


G 


235 


C» 


199 


G# 


236 


D 


201 


A 


237 


D» 


203 


A# 


238 


E 


207 


B 


239 


F 


209 


C 


240 


F# 


212 


G# 


241 



By POKEing values into the first three voices (SI -S3}, you can 
even play tunes. (''White noise" isn't really appropriate to this 

73 



kind of thing.., unless you dream of playing first-chair computer 
with Pink Floyd!) Unfortunately, this POKE process is very slow 
and tedious for a human... but it's child play for your VIC. So 
let's put the POKEs in a program and let the computer do the 
work! Anyone for "Flight of the Bumble Bee"? How about the 
"Maple Leaf Rag"? 

THE "WHITE NOISE" GENERATOR 

The fourth voice, S4, is numbered 36877. WeVe called it "noise'' 
because it's actually a "white noise" generator, used primarily 
for special effects. Try making the buzz of an airplane: 

POKE V, 6 
P0KES4, 130 

If s a four-engine prop job, right? Now, how about the wind 
whipping by the wings of a sailplane? 

POKE S4, 240 

Don't forget to turn on the volume with: 

POKE V,4 

or whatever volume setting you like best. Now let's turn off the 
sound: 

POKE S4, 





74 



PLAYING SONGS 



Using the VIC speakers and table of musical note values, you 
can make up your own songs, or transcribe tunes from a 
songbook. The following songwriting program shows you how 
to do it: 



NEW 

10 52 = 36875 

20 V =36878 




200 REM IF NOTE-1 THEN STOP 
210 POKE V,0 
220 END 



yT T T 

300 DATA 225, 1000, 228, 1000, 231, 1000 

310 DATA 232, 1000, 235, 1000, 237, 1000 

' ^ ^ ^ 



320 DATA 239, 1000, 240, 1000 /^VV^l 
330 DATA-1 < l^heendV 

In the first group of instructions then, we've set up the POKE 
locations for the speal^er{s) we're using, in this case speaker 
2 and volume, and entered our abbreviations. The next group 
of instructions begins at line 100. 



l?k 



Line 100 contains a REMark which explains what this section 
IS supposed to do. it's called a "loop" because the section 
will read and play one note, then "loop" back to the 
beginning and do it again for another note. Line 110 turns up 
the volume. *^ 

Now we'l/ tell the VIC to find out what note to play: 



ViCTiP: 

Programs don't have to start with line #1, or be 
numbered by 1. Most programs start at 10 and go up in 
increments of 10. This way you can go back and add 
extra lines in between if you want. For example, you 
could add a line 11,12, etc. between lines 10 and 20 



Line 120 tells the VIC to look through the program and READ 
information — call it P — about what note to play. This 
information is contained in a "mystery statement" that we 
haven't written yet. Similarly, line 140 tells the VIC to READ 
information — call it D — about the duration of the note. 

Notice especially line 130. The function of this line is to stop 
the program when the last note has been tead. Without some 
kind of "end of melody" marker, the program would try to read 
notes that haven't been written, and make an error. Line 130 
says that when the VIC reads this marker, a value of -1 it 
should not try to play this note, but go to an ending module at 
line 200. We must remember to place -1 at the end of our 
"mystery statement." 

Now we'll have the VIC actually play the note, cut it off, and go 
back for another: ^ 




C 

c 
c 

c 

c 
c 

c 
c 



c 



76 



( 



Line 150 simply POKEs the note we READ in iine 120 into voice 
1, whiie iine 160 creates a deiay for the duration we READ in 
line 130. Similarly, lines 170 and 180 turns off voice 1 for a short 
period. Line 190 sends the ViC back to iine 120 to READ the 
next note. 

Now we have to write our ending section. Remember that our 
"end of melody" marker, -1, sends the program to line 200. 

Line 210 turns the voice off, and line 220 tells the VIC to stop 
performing the Instructions in this program. 

Even though we've written the ending section, we're not quite 
done. We still have to write our "mystery statements" to tell 
the program what notes to READ. These mystery statements 
are called DATA statements because they contain information, 
or data, DATA statements can be located anywhere In a 
program. Whenever the VIC encounters a READ Instruction, it 
looks around for a DATA statement to READ, 

This module contains the DATA for a C major scale. Line 300 
contains the first three notes. The first number is the POKE 
value for the first note, 225 — low C. The second number sets 
its duration, 1000 — about 1 second. Line 310 contains the next 
three notes, and line 320 the last two. The values themselves 
are taken from the table of musical notes above. 

If the lines look correct, youVe ready to RUN. You should hear a 
fairly accurate C major scale! If you have a "clinker" or two, try 
adjusting the values In your DATA statements, starting at line 
300. 

Once again: You can put DATA statements anywhere In your 
program. They will be READ one by one, starting with the 
lowest line number, and working tfirough each DATA statement 
from the beginning to the end. 



77 



Try substituting DATA statements to play other selections. For 
example, tiere's an old family favorite: a. 



300 DATA 
310 DATA 
320 DATA 
330 DATA 
340 DATA 
350 DATA 
360 DATA 
370 DATA 



225. 360, 
228, 120, 
228, 120, 
235, 720, 

231, 360, 

232, 120, 
225, 480 
-1 



225, 360, 
231,360, 
231,240, 
240, 360, 
225, 360, 
231,240, 



225, 240 
231,240 
232, 120 
235, 360 
235, 240 
228, 120 





Or if you prefer classics: 



DATA 217, 400, 213, 400, 223. 400 
DATA 227, 200, 234. 200, 230, 400 
DATA 227, 200, 234, 200, 230 400 
DATA 223, 400, 227, 400, 217, 400 
DATA213, 600. -1 



use as many ' 
lines as you 
like to play 
longer selections 
but for the 
purpose ol this . 
program, sticl< 
to 3 notes 
per line. 



THE VIC AS PIANO 

Finally, here's a program that lets you play the VIC's keyboard 
like a piano; 

NEW 

10 REM STORE SOUND REGISTERS 
20 S2 = 36875 
30 V =36878 
40 P0KES2, 

100 REM STORE B MAJOR SCALE 
110 F0RN = 1 TO 8 
120 READ A (N) 
130 NEXT N 



140 DATA 223, 227,230 
150 DATA 231, 234,236 
160 DATA 238, 239 

200 REM PLAY KEYBOARD 
210 POKE V, 3 

220 GETAS: IFA$ = ""THEN220 
230 N = VAL(A$) 

240 IF N =0 OR N =9 THEN 300 




c 
c 

# 

c 

( 

( 

C' 

c 
c 
c 

( 

c 

( 

c 

c 

( 

( 

( 

( 

( 

( 

( 

( 

( 

c 

# 

c 

c 

( 

c 

c 



250 POKES2,0 

260 F0RT = 1 TO 25: NEXT T 

270 P0KES2, A(N) 
280 GOTO 220 

300 REM ENDING MODULE 
310 POKES2,0 



Brief silent interval 
between notes. ..Shhhhh 

Plays the tone 
and returns to 
look for another 

Turn off the sound 
before you go 



Now, when you type RUN (and press RETURN ), you can 

play tunes on your VIC. The keys in the top row with numbers 
on them control the various notes: 



1 


2 


3 


4 


5 


6 


7 


8 


DO 


RE 


Ml 


FA 


SOL 


LA 


Tl 


DO 



*********! 



^ «««*** * 1 



The VIC will keep playing the note you hit last until you hit 
another note. When you're done, press either or 9, and i! will 
turn off. To start the VIC piano again, just reRUN the program. 

Try the foliowing (sing along if you wish): 



1 


1 


5 


5 


6 


6 


5 




4 


4 


3 


3 


2 


2 


1 




5 


5 


4 


4 


3 


3 


2 




5 


5 


4 


4 


3 


3 


2 




1 


1 


5 


5 


6 


6 


5 




4 


4 


3 


3 


2 


2 


1 


8 



OR: 



3 3 

1 1 

3 3 

1 1 



4 
2 
4 
2 



5 
3 
5 
3 



4 
2 
4 



3 
2 
3 



1 1 



Take it away, Ludwig! 



79 



A FEW WORDS f 

ABOUT POKE [ 

The command POKE lets you deal with your VIC on a (^ 

completely new level. POKE allows you to find a particular 

memory location and change what is stored there. Since this C 

command operates directly on the VIC'S memory, it is possible ^ 

to make mistakes by POKEing values into the wrong locations, 

or wrong values into the right locations 1 We want to repeat ^ 

what we told you way back in Chapter One: There is no way ^ 

you can hurt the computer by typing on the key board... noi even 9" 

with POKE. But you can cause the VIC to just go away x 

someplace and sulk, cutting you off from any contact. For 

example, if youVe ready to end this session anyway, try typing: C 

POKE 788, ^ 

You may find that the only way you can regain communication 

with a computer that has been "insulted" in this way is to type ^ 

RUN/STOP and RESTORE. If the "crash" is serious, you may 

have to turn it off and turn it on again. This doesn't harm the 

computer, but it does mean that whatever program you were ( 

working on will be lost. Even if this should happen to you, a 

little typing time is normally the extent of the loss. But it does C 

suggest that you should be careful of what you POKE. It also ^ 

underlines the value of accessories like disk drives and data ^ 

cassettes, which can store programs, as well as printers, which (^ 

can at least give you a program listing that would help you 

reconstruct a lost program. w 

We recommend that you make a brief study of POKE m ^ 

Appendix C before you begin to POKE around indiscriminately ^ 

in your VIC. At least try the examples we give you in this book. 

Be careful typing those long numbers, and double check your • 

work before you run your programs. A computer that has been g| 

POKEd in the wrong place may well reason that turnabout is 

fair play, and simply "turn you off." 

In this chapter, you've learned how to make Bach and 
Beethoven sit up and take notice. You know how to drive your 
friends crazy and make them long for the good old days when 
your VIC was a quiet, mild mannered little creature that kept 
pretty much to itself. So what if the VIC Isn't quite as talented 
as Beveriy Sills or a Steinway concert grand? You and VIC can 
still make beautiful music together! fs^aestro, please,.. 



c 



( 

i 



Try typing this program: 

Type this program exactly as shown and see 
what happens! 



C 

c 

c 
c 



10 INPLTP'DEGREES FAHRENHEir';F 

20 PRINT P'DEGREES F." 

30 PRINT"IS"(F-32)-5/9"DEGREES C." 

40 PRINT - 

50 GOTO 10 



To stop the program, press the 



and hit 



RESTORE 




82 



c 

<: 

Typing the J 
word PRINT\ 
by itself i^ . 
on a line J 

adds a blank ( i 
line when r^ 
the program v 
is run. Try \^ 
it with and y 
without this y 
line 

(. 

c 
c 
c 
c 
c 
c 
( 
( 
c 
( 
c 
c 



Good morning VIC. Your mission (and we know you are going 
to accept it) is to perform miracles whenever we touch just a 
few keys! 

Yes, your VIC is ready, able and willing to respond to your 
touch like no other computer ever made. So let's buckle down 
to some non-stop fun! 



key. 



Hold down the HSSV ^^Y and press the 

Type the following keys; 

[n] [H^ and press the 
key. 




CDiwi E] B mai l 

Eds E 

mm s^sds® 

and the ^^^^B key. 



{2\ [BDmHmE] 

and the ^^^^H key. 

m io] dl [Q] m and the 



key. 



Now press [r] [u] [n] and 




83 



And the VIC responds: 



1 INPUT "WHAT'S YOUR NAME";A$ 

2 PRINT" HI, "A$ 



3 GOTO 2 



WHATS YOUR NAME? 



Notice that i-^f 
the computer 
automatically x . 
adds the quest iori/^ ) 
mark (?) to show ) 
you that it's 
waiting lor 
an input. 



At which point you type in the customary response or if your 
name happens to be VIC you can type: 

[v] [□ [C] and 



And whoopee! Your name splashed all over the screen! To 
slow down the show just press the fj^fl Key. When you 



are ready to leave stardom behind, press the ggj key. 

To enter another name just type RUN and you will see the 
same prompt again. The prompt in this case is: 
WHArSYOUR NAME? 

Prompts are questions directed to you in an effort to get in- 
formation into the VIC. The VIC has a limited number of ways 
to get information from the human world. Perhaps the most 
useful method for the computer to collect information from 
our keyboard is the INPUT statement. Let's go through the 
steps of our program. Here's what we told VIC to do: 

First, display the message "WHATS YOUR NAME" on the 
screen and then wait for you to put in (or INPUT) characters 
from the keyboard. Take the response and name it '^A$'\ In 
our example "VIC becomes A$. This is a kind of shorthand 
for the computer. 

Second, print the word "HI" followed by whatever was typed 
at the keyboard. In our example we print HI VIC. 

84 



c 
( 
( 

( 
c 

( 
( 
c 
( 
( 
( 
c 



Third, go back to line number 2. 

The second and third steps combine to make the VIC con- 
tinuously print the message "HT' all over the screen. If we 
changed line 3 to read: 

3 GOTO 1 

then the message HI VIC would print on the screen only once 
and the message prompt "WHAFS YOUR NAME" would ap- 
pear again. This alteration makes the VIC appear to have 
amnesia! 

Whenever we use the INPUT statement, our program holds 
everything while awaiting a response from you. ft is important 

to note that VIC will wait forever or until the RETURN key 
is pressed, whichever comes first. 

In our program we created a friendly prompt. Unless we tell 
the VIC what we want our input message to say, we will just 
get a simple "?" which does not tell us much. So we will try to 
build prompts which suggest what type of input is 
required. 

Press CkJ and M^M at !he same time. 



NEW 
READY 
1 INPUT A$ 



Type NEW and 

1 INPUT A$ 

When we type RUN the 
VIC screen looks like: 

The question mark alone 
raises more questions than it 
answers! So let's try this: 

1 PRINT "MAY I HAVE YOUR NAME":INPUT A$ 

2 PRINT "WHAT IS YOUR FAVORITE FOOD":INPUT B$ 

3 PRINT 

4 PRINT "THANK YOU,"A$" FOR YOUR POLITE ANSWER" 



5 PRINT "WE WILL GIVE YOU SOME mj|||g "B$" 
AS A GESTURE OF OUR APPRECIATION" 



After typing RUN and |^^^^^ you will see that treating 
messages with respect can result in a treat for your efforts! 

85 



INTRODUCING VARIABLES 

Many of the programs used in this book use variables to 
simplify or strengthen the program. 

Variables are very useful because they can be used to repre- 
sent numbers, formulas, graphic symbols, words, phrases — 
even whole sentences. Examples of variable names are: X, A8, 
S2, X$, AB$, S2$. The easiest way to explain the power of 
variables is to tell you that these simple variables can each be 
used to represent up to 255 characters! 

There are two kinds of variables; numeric variables and string 
variables. Numeric variables are used to store numbers (ap- 
tually, numeric values). String variables can be used to store 
all types of characters (numbers, letters, graphics, cursor con- 
trols, color controls, etc.). 




BOX A 



BOX AS 



Variables are like storage cabinets inside the computer. To tell 
the VIC that cabinet is for numbers or values, we must use a 
special name. Numeric variable names may be one or two 
characters long and may be one letter, two letters, or a letter 
and a number. Here are some examples of numeric variable 
names: 



AB 



S2 



C2 



AA 



ZX 



String variable names may be one, two or three characters 
long (including the $ sign), must always begin with a letter 
from A to Z and have a dollar ($) sign at the end. Here are 
some string variable examples: 

X$ AB$ S2$ C2S A AS ZX$ 



c 
c 
c 
( 
c 
c 
c 
( 
f 
c 
c 
( 
( 
( 
( 
( 
(, 

( 
c 



86 






Here's a short program that shows one way to use variables: 

10A$ = "VIC20" 

20 PR1NT"HELL0,"'A$ 

RUN 

The VIC will display HELLO, VIC 20. Why? Because in Line 10 
we told the VIC that the variable A$ is the same as "VIC 20". 
Now try this: 

IDA = 2 

20B = 3 

30C = 4 

40PRINTA*B*C 

In this example, A*B*C is the same as 2*3*4 because we 
"stored" the numbers 2, 3, and 4 in the variables A, B, and G. 

Here's a final example that uses two kinds of variables with 
INPUT statements. The INPUT statement allows the person 
running the program to define what the variable will stand for 
like this: 

10PRINT"WHAT WORD DO YOU WANT X$ TO STAND FOR": 
INPUT X$ 

20PRINT"WHAT NUMBER DO YOU WANT X TO STAND FOR": 
INPUT X 

30PR!NT"NOWXS STANDS FOR" X$ 

40PRINT"AND X STANDS FOR" X 

RUN 



ff? 



CHOOSE A NOTE 

For this INPUT example we will tinker a little with VIC sound. 

Type: 

NEW 

10 iNPUT"HOW HIGH A NOTE";t 

20 IF H=0THEN90 

30 INPUP'HOW LONG A NOTE";L 

40 POKE 36878,15 

50 POKE 36875,H 

60 F0RT = 1 TO LNEXT 

70 POKE 36878,0 

80 GOTO 10 




c 
c 
c 

( 

c 
c 
c 
c 
c 
c 
c 
c 



90 END 

After you press 



the screen should look like this: 



HOW HIGH A NOTE? 225 



HOW LONG A NOTE? 1000 



Type a number 
from 128 to 254 



Press the ^mmm^g Key and listen to the prtch and dura- 
tion of the note. After each note you can create another and 
gain an appreciation for how these '^mysterious" POKES 
translate into sound. 



The first two lines of "make a note'* (10 and 20) give us the 
flexibility necessary to vary the pitch in line 50 and 60 respec- 
tively. Line 30 is our "door" out when we are finished ex- 
perimenting (just type (zero) in response to HOW HIGH A 
NOTE?). Line 70 turns off the voice which was activated 
earlier in line 40. 

If you want all the noteworthy details on making music with 
your VIC, turn to chapter five. 



THE GET STATEMENT 

Now that you have mastered the INPUT statement, we will 
move on to a fancier way of getting information from the 
keyboard. 

The GET statement is used to get characters from the 
keyboard one character at a time. In fact, the person RUNning 
the progrann need not even hit the RETURN key! Here's how 
the statement looks! 

lOGETAS 

How do we make a program stop and wait for something to be 
typed? We put the program in a loop with an IF. .THEN state- 
ment checking for an answer. 

10GETA$ 

20IFA$ = ""THEN 10 



What is the use of this? For a very simple application, the lit- 
tie 2 line program above will allow your program to pause until 
the operator hits a key on the keyboard. This is helpful in 
freezing a display on the screen until the person has read it 
and wants to go on. 

Here is an expanded application for the GET statement: 

10GET A$ 

20IF A$^""THEN 10 

30 IF A$ = "A" THEN PRINT ^'CHICKEN SOUP" 

40 IF A$ = "B" THEN PRINT "SPAGHETTr' 

89 




50 IF A$ = "C" THEN PRINT "STEAK AND EGGS" 

60 GOTO 10 

RUN 

When this program has been typed in and RUN, it will wait for 
the operator to hit any key. If the key was the letter A, the 
words, CHICKEN SOUP appear on the screen. The letter B 
makes the word SPAGHETTI appear, and the word C makes 
the words STEAK AND EGGS show up. You now have the VIC 
typing whole words with only 1 keystroke! 

Now you will get the longest program so far, a practical exam- 
ple of the GET and PRINT statements used to give you a com- 
puterized recipe file. Don't be alarmed by the size of this pro- 
gram. It uses mostly simple PRINT statements but the lesson 
here is how the A$ variable is used to stand for several whole 
phrases, and how the GET command 



10 PRINT " m^^ Ujg PLEASE PICK A CHOICE-' 

20 PRINT "FROM THE MENU:" 

30 PRINT 

40 PRINT "A. ..CHICKEN SOUP" 

50 PRINT ■■B... SPAGHETTI" 

60 PRINT "C... STEAK & EGGS" 

200 GET A$:IFA$ = ""THEN 200 • 

210IF A$ = "A"THEN 500 

220IF A$ = "B"THEN 700 

230 IF AS = "C" THEN 900 

490 GOTO 200 

500 PRINT " ^^^1 IS) MIKE'S CHICKEN SOUP" 

510 PRINT 

520 PRINT "TAKE 1 CHICKEN. KILL" 



90 




o 
( 

( 
( 
( 
( 
( 
( 

c 

i 
< 
( 
( 
( 
( 
( 
( 
( 

o 
o 

( 
( 
( 
( 
( 
r 
c 
( 



530 PRINT "AND PLUCK. REMOVE" 
540 PRINT "GIBLETS. BOIL 4 QTS" 
550 PRINT "WATER IN A LARGE POT." 
560 PRINT "ADD CHICKEN. BOIL" 
570 PRINT "2 HOURS, OR UNTIL" 
580 PRINT "HOUSE SMELLS GOOD." 
590 PRINT < 



600 PRINT "HIT ANY KEY TO GO ON" 
610 GET A$:IF A$ = "" THEN 610 
620 GOTO 10 





700 PRINT" mH^ Jjlj^ MA'S SPAGHETTI" 
710 PRINT 

720 PRINT "BROWN 1 LB. GROUND" 

730 PRINT "BEEF, WITH 1 ONION" 

740 PRINT "AND 1 GREEN PEPPER. ' 

750 PRINT "ADD 1 LG. CAN TOMATO" 

760 PRINT "PUREE. 6 OZ. CAN TOM." 

770 PRINT "PASTE, 6 OZ. WATER," 

780 PRINT "3 CLOVES GARLIC, SALT" 

790 PRINT "& PEPPER, RED PEPPER." 

800 PRINT "OREGANO. SIMMER 1 HR" 

810 PRINT '& SERVE WITH COOKED" 

820 PRINT "NOODLES." 

830 GOTO 590 



91 



900 PRINT '■ 
910 PRINT 

920 PRINT "TAKE 1 COOKED STEAK' 

930 PRINT "AND COOKED EGGS." 

940 PRINT "SERVE TOGETHER WITH 

950 PRINT "BEVERAGE." 

960 GOTO 590 



STEAK AND EGGS" 



If you typed the program 
correctly and typed RUN. 
the screen should come up 
with the following display: 



PLEASE PICK A CHOICE 
FROM THE MENU: 

A...CHICKEN SOUP 
B... SPAGHETTI 
C... STEAK & EGGS 



^ ^ 



Now the VIC is wailing for you to hit a key. If you type 
anything other than A. B, or C, nothing happens at all (Line 
200 does this). If you hit the A, you get the recipe for Mike's 
Chicken Soup. Pretty terrible, huh? You can tell Mike is a 
bachelor. 

This can be lengthened and modified very easily for your own 
use. To add items to the menu, just add a PRINT statement 
after line 60, add a new IF statement after iine 230, and add 
the recipe wherever there is room at the end. The last line of 
your recipe should be the line GOTO 590, which tells the per- 
son RUNning the program to hit a Key to continue. This will 
keep the recipe on the screen until they are through with it. 

You can use the program we just described for more than 
recipes, of course. How about a name and address file? In- 
stead of a "menu'' use last names with initials. Instead of 
recipes, use the person's name, address and phone number. 
Can you think of other uses for GET and INPUT based pro- 
grams? This is the true power of computing — being able to 
tailor what the computer does to your own needs. 

92 



. 1^^-%^^ 



Try typing this program: 

Type this program exactly as shown and see 
what happens! 



10 PRINT 



20 PRINT CHR$(205.5 + RND(1)); 
30 GOTO 20 



To stop the progrann, press the ^M key. 




94 



c 
c 
c 

c 
c 

c 
c 
c 
c 
c 
c 
c 
c 
c 
c 
c 
c 
c 
c 
c 
c 
c 
c 
c 
( 
c 
( 
( 
( 
c 
c 
( 
c 
( 



YOUR FIRST BASIC 
PROGRAMS AND HOW 
THEY WORK 

Until now, you've been patient and typed in several programs 
without understanding how they work. This chapter will explain 
what those tricky little programs were all about, and get you 
further along the road to progrannming your VIC. 

PROGRAM 1: Your Name In Lights 
(Chapter 2) 



10 PRINT ■' 

20 F0RT = 1 TO 300: NEXT 
30 PRINT "Vour name" 
40 FOR T = 1 TO 300: NEXT 
50 GOTO 10 




There doesn't seem to be much to this little program, but once 
you understand what's going on here, you have the key to doing 
animation. Line 10 is the PRINT command, with the character 
meaning ''clear the screen" inside the quote marks. If you tried 
to type this without the quotes, your program line disappeared 
from the screen before you could finish typing it. The VIC only 
recognizes a new line when you hit the RETURN key with the 
cursor on that line. 




95 



/' 



VIC TIP: QUOTES 

Let's talk a little more about what happens when you hit the quote key. 
The first time you hit the quote, something tunny happens. If you hit 
HOME, CLR^ cursor up, down, left, or right, you get a reversed graphic 
character. This also happens on the VIC when any of the color control 
keys are pressed. You see, quotation marks are used in computer 
programs and the VIC recognizes quote marks as a Programming 
Command, Therefore^ when you htt a color or cursor control key after a 
quote mark, the VIC displays a special code to designate that 

operation. For example when you type '* and 

you get a reverse heart on the screen. If you see 

thts in a program you know it means clear screen. Other symbols 
stand for other operations. Once you have hit the quote key for the 
second time, any cursor controls and color keys will work normally. 

The INSERT key causes a similar effect. When this key is hit, every 
space created on the line will act as if ft was in quote mode. Alf cursor 
control characters will appear as if they were inside quote marks. In 
addition, the DELETE key will produce a special reversed graphic 
character m these spaces, which will have the effect of deleting 
characters when the program is fisted, and printing DELETES on the 
screen when PRINTed. 



Line 20 of the program is called a time delay loop. This is 
actually two BASIC statements on one line, separated from 
each other by the colon {:). All that happens here is that the VIC 
will count from 1 to 300, without doing anything else. This 
serves to slow down the program a little. (Try deleting the lines 
20 and 40 and RUNning the program. It blinks too fast!) 

In line 30, you typed your name inside the quotes (At least we 
hope you did,) This caused your name to be printed on the 
screen. There was nothing else on the screen because line 10 
already cleared it off. 

Line 40 is another delay, to give your name time to be on the 
screen long enough to see. 

Line 50 causes the program "go to" line 10 as the next line to 
be executed and briefly clears the screen. 

After your name is displayed on the TV screen, there is a delay 
of a second, after which the screen is erased. After another 
second, the name is dispiayed again in the same position. 
Again, it is erased, and so on. Because the letters appear in the 
same position on the screen, your eye believes that they are 
blinking on and off. 

96 



c 

c 

c 

c 

c 

c 

o 

o 

c 

c 

c 

c 

c 

c 

c 
c 
( 
c 

( 
( 

( 
c 

c 
( 
( 
( 
( 

( 

( 
c 



Experiment with this program. You can make the defays 
between displaying and erasing your name longer or shorter by 
changing the number 300 in lines 20 and 40. 

PROGRAM 2: A Lot of Heart 
(Chapter 3) 



10 FOR H = 


= 1 TO 505 




20 PRINT ' 


■ V"; 




30 NEXT 






40FORC = 


= 8 TO 255 STEP 17 


50 POKE 36879. C 




60FORT = 


= 1 TO 500: 


NEXT 


70 NEXT 






80 GOTO 40 





This program provides you with a colorful display of hearts. It 
introduces the use of punctuation marks in PRINT statements 
and the use of POKE to change the screen and border colors. 

Line 10 sets up a loop that counts from 1 to 505. We want 505 
hearts to appear on the screen, because there are 506 spaces 
on the screen. If we PRINTed the 506th character, the screen 
would be forced to roll up one line (scrolfing), and there would 
be less hearts on the screen than before. 

Line 20 PRINTs the heart character on the screen. The semi- 
colon (;) after the last quote has an important effect. You see, 
after a normal PRINT statement, the VIC will automatically 
perform 2 operations — move the cursor back to the beginning 
of the line (called a carriage returrj), and move the cursor down 
to the next line {called a linefeed}. The punctuation mark at the 
end of the line will cancel the return and linefeed, so that the 
next thing PRINTed will appear immediately to the right of the 
last thing PRINTed. 

Line 30 just completes the delay loop. As fong as the value of H 
is 505 or less, the program will print hearts on the screen. When 
the 505th is printed, the program continues with the line after 
this one (line 40). 



97 



Line 40 establishes a new foop and sets up line 50, wliicli 

clianges the screen and border colors. C Is defined as a series 

of numbers from 8 to 255, which Increase in increments of 17. 

Every time line 70 (NEXT) is hit, 17 is added to the previous 

value of C and the sum is used for the new value. This causes a 

cycle of colors to be selected Including blacK border with black 

screen, white border with white screen, etc., for all 8 border 

colors. Then the numbers in C go beyond the values for those • 

colors and pick 7 different colors for the screen. (See Appendix /-=, 

I for a list of color numbers) ^ 

( 
Line 50 is the statement that actually changes the color: The 
value contained in variable C is stored in memory location ^ 

36879, This is actually a location on the VIC chip itself, not in r 

your normal area of memory. 

( 

Line 60 is a delay loop. If this line is removed, the colors will 

change fast enough to give you a headache. ^ 

Line 70 completes the loop started in line 40. Notice that the 

line could have read 70 NEXT C, but doesn't have to be that ( 

way. 

Line 80 sends the program back to cycle through the colors ( 
again. It will run forever, unless you press the STOP key, or turn 

off the VIC. Typing POKE 36879, 27 after you hit STOP will C 

restore the normal colors of the screen. ^ 

c 

c 
c 
c 
• 



c 
c 



98 



PROGRAM 3: Exercising VIC Person 
(Chapter 4) 



10 


PRINT " 




20 


PRINT ■ 


KDL^" 


30 


PRINT' 


■ s_" 


40 


PRINT ' 


•/ :^" 


50 


FORT = 


= 1 TO 300: NEXT 


60 


PRINT ■ 


' ggjjg "; 


70 


PRINT ' 


■Lia •■ 


80 


PRINT' 


■zm^- 


90 


PRINT 


re 


100 


FORT: 


= 1 TO 300: NEXT 


110 GOTO 10 



This program is similar to the first program we did, called Your 
Name in Lights. However, instead of drawing an image and 
then blanking it out, like the first program did, this one draws a 
complete picture, pauses, and replaces the image with another 
complete picture. The head and body of the VIC person stays in 
the same position while the arms and legs change places. This 
gives the illusion of movement from one position to the next. 

Lines 10 and 60 bring the cursor to the upper-left corner of the 
screen, which is known as the home position. This forces the 
image of the VIC person to be displayed in the same screen 
position each time. 

Lines 20, 30, and 40 will "draw" each line of the VIC person's 
first image. 

Lines 50 and 100 are delay loops, just to give the picture 
enough time on the screen. 

Lines 70, 80, and 90 draw the second image on the screen. This 
takes place so fast that you can't see the transition — your eye 
sees the change from one to the other as instantaneous, 

99 



PROGRAM 4: 
(Chapter 5) 



Choose A Note 




NEW 
10 PRINT' 

FOR I - 1 TO 5 
POKE 36873+ 1,0 
NEXT I 



PRINT "WHICH VOICE (1-4)?" ( 
PRINT "IF DONE, ENTER 0" 

INPUT N 

IFN=OTHEN END < 



These lines clear the 
screen and turn off 
all voices 

These lines allow 
you to select a 
voice 



PRINT "WHICH PITCH (128-254)?" 

INPUT P < 

POKE 36878, 4 — 

POKE 36873 -I- N,P 
FOR J = 1 TO 2000: NEXT N 
GOTO 10 



Mhis line ends 
the program 

These lines 
allow you 
to select 
a pitch 




These lines poke the note 
and volume, and provide 
a 2-second delay 



When you've checked that all the lines are correct, try running 
this program (type RUN and press RETURN). It will let you 
select a voice and a pitch, and play the tone you've chosen for 
about two seconds. The sound shuts off, and the program asks 
you for another voice and pitch. This program is a musical 
experimenter's delight, so be sure to give it a try. When you 
wish to stop the program, enter as a voice selection. You may 
suspect there's a problem when you select pitch 254 in voice 3 
and hear nothing. Actually, it's not an error — this note is just 
too high for human ears, (you might test it out on your dog 
though!) 



too 



C 

o 

c 

( 

o 

( 

( 

c 

( 

( 

( 

( 

c 

c 

c 

( 

( 

c 
c 

( 
( 
c 
c 

« 
c 



PROGRAM 5: Temperature Conversion 
(Chapter 6) 



10 INPUT "DEGREES FAHRENHEIT"; F 


20 PRINT F "DEGREES F." 


30 PRINT "IS" (F-32)*5/9 "DEGREES C." 


40 PRINT 


50 GOTO 10 



This introduces you to the INPUT statement, which aiiows your 
program to stop what it is doing and request necessary 
information from the operator {the person who is RUNning the 
program). 

Line 10 causes the message DEGREES FAHRENHEIT? to 
appear on the screen. The words inside the quotes of an iNPUT 
statement work just like the PRINT statement. However, the 
last word will always be followed by the question mark 
character^ and the program will wait at this point for more 
information. 

Line 20 prints the value of F, which is what was just typed in 
(inputted). Line 30 prints the result of the conversion 
calculation. In line 40, the word PRINT alone on a line causes a 
blank line to appear on the screen. 

Finally, line 50 makes the program go back to the beginning 
and request more information to start again. The original 
question wMI be asked agam, and you can have more 
temperatures converted. If you are finished, hold down the 
STOP key and hit the RESTORE key. There is no other way to 
tell this program you are through. 



101 



PROGRAM 6: Random Maze 
(Chapter 7) 



10 PRINT" 


m 


GB9 


It 


20 PRINT CHR${205.5 


+ RN 


D(1)); 


30 GOTO 20 









This is a neat little program that prints pseudo-mazes all over 
the screen. As you may expect, line 20 is the key here. 

The CHR$ function will give you a character based on a code 
number from to 255. Every character that the VIC can put on 
the screen is encoded this way (see AppendixH). To find out 
the code for any character, just type PRINT ASCi"X") where X Is 




the character you're checking. Then type PRINT CHR${X) where 
X is the number the VIC gave you. See how it works? 

Now try typing PRINT CHR$(205); CHR$(206}. This should print 
the two right side graphic characters on the M and N keys. 
These are the two characters that the program is using for the 

"mazes". 

By adding the formula 205.5 + RND(1), the VIC will pick a 
random number between 205.5 and 206.5. There is a fifty-fifty 
chance of the number being above or below 206. When the 
CHR$ function works, it will ignore any fractional values. 
Therefore, half the time the character with code 205 is 
PRINTed, and the other half character code 206 PRiNTs. 

If you'd like to experiment with this program, try changing the 
205.5 by adding or subtracting a couple of tenths from it. This 
would give either character a greater chance of being PRINTed. 



102 



# 
c 

• 

#' 

c 

( 

( 

{ 

( 

( 

c 
( 
c 
( 
( 
c 
( 
( 
c 
( 
( 
( 
c 
c 
c 
c 
c 
c 
c 



MORE ABOUT RANDOM 
NUMBERS 

The random number function is one of the most useful and 
enjoyable aspects of BASIC, allowing you to program all sorts 
of games of chance. 

The line X = RND(1} will cause the VIC to select a random 
number between and 1, not inclusive, to be placed into X. This 
results in a range of possible values for X: 

0<X<1 

When you work with random numbers, it is best to keep in mind 
that you will generate a range of numbers, to see how 
calculations effect the whole range. For example, if you wanted 
to get a set of possible values between and 3, you could just 
multiply X by three. The new range is: 

0<X<3 

If you needed to pick a number from 10 to 20, how would you 
perform a calculation to change the range? First, you would 
add 10 to the number picked, to change the range to 

10<X<11 

By multiplying the random number by 10 before adding 10, the 
range becomes: 

10<X<20 

So the formula for a random number between 10 and 20 is: 

X = RND(1)*10 + 10 

So far, we have learned how to change the range of possible 
results for the random number. However, the result of the 
function will contain messy decimal places, which are not 
desirable for things like rolling dice or picking a number from 1 
to 10. The function used to clean this up is the INT function. 
This will chop off alt decimal places from the number. The 
formula for a random number from 10 to 20, with the INT 
function added, becomes: X = INT(RND{1)*10 + 10) 



103 



The range of possible results is now: 
10<=X<=19 



The general formula for a set of random numbers in a certain 
range is: 

X = INT{RND(1}*a) + b 

Where a represents the number of possible results and b is the 
lowest number in the range. 



( 
c 
c 
c 



( 



But wait! The upper limit of the range has dropped from 20 to C 

19 in this case. Why? Because before the range was always 

less-than 20. The INT function will strip off any decimal places 

from a number greater than 19 and less than 20 to result in a r 

19. On the other end of the range, any results between 10 and 

eleven are truncated down to an even 10. If we still needed to 4 

get a range of numbers from 10 to 20, the formula should ^ 

become: ' 

X = INT{RND(1)*11+10) 

The random number is multiplied to expand the range, and ^ 

added to move the range. 



( 
( 

c 
c 
( 
( 

( 
( 

c 

c 

# 

c 

m 

c 

( 
( 
( 
( 
( 

104 ( 

( 



APPENDIX A: VIC ACCESSORIES — 
A QUICK INTRODUCTION* 

This is a beginner's user manual, so we are not going to spend a lot 
of time and space telling you about the various peripherals that plug 
into the slots on the back of your VIC, 

Each of the VIC peripherals will have its own instruction manual, 
which will tell you how to connect it to the VIC and how to use tt to do 
interesting things. 

Commodore has designed the VIC to grow with your needs and has 
an overall plan of how the various peripherals will fit together in and 
on the VIC, Here is the map of that plan; 



THE COMMODORE VIC 20 
PERSONAL COMPUTER SYSTEM* 



( 
C 

c 
c 
( 

c 
c 
c 
c 
c 

c 



( PRJNTEH J 



DISK 
DRfVE 



MOPfiTOfl 






PLSJQIN 



CABLE 



^ 



MAI-iTFR CC"-AfHCL 
BOAPD 



CflSSETT 

POaf 



v:CieO 
OUTPUT 



VIC 20 COMPUTER 



GAWE PORT 



1 JOVSTtCK 
Ofl 

i LiGHTPEN 

i PADDIES 



SPECIAL PLUG-IN PROGRAMS 

Super Expander Cartridge — 3K Added Memory (converts VIC to 8K) 

Higti Resolution Graphics & Plotting 

Commands 
Pre-assigned Function Keys 

Programming Aid Cartridge — Programmer's "tool kit" 

Mactiine Language Monitor 
Pre-assigned function keys 

(prog commands) 
User-assignable function keys 

'Note: Peripherals described in this section scheduled for sale during 
late 1981. 



106 



( 
( 

c 
c 
( 

( 
c 
c 
( 
( 
c 
c 
c 
( 
c 
( 

( 
c 



TAPE CASSETTE RECORDER 

The first peripheral you will probably get will be the Commodore tape 
recorder. The tape recorder can store several thousand characters 
(letters and numbers) on an ordinary cassette tape. You can store 
quite a few long programs on tape and load them back fairly quickly, 
without having to type them in every time. (See Appendix B - Working 
With Tape Cassettes) 

The VIC Tape Cassette plugs into the Cassette Interface slot on the 
back of the VIC with its own special plug — it does not need any 
special interface. Commodore provides a variety of computer 
programs on tape for use with the cassette recorder. 



MASTER CONTROL PANEL 

You can plug a Master Control Panel in to the Expansion Port on the 
back of the VIC. This controller lets you use more than one cartridge 
at one time- It has six slots and accepts program cartridges, memory 
expanders and includes an IEEE-48S interface which lets you use 
Commodore PET/CBM peripherals and other IEEE devices. 



VIC SINGLE FLOPPY DISK DRIVE 

The VIC Single Floppy Disk Drive can store up to 170,000 characters 
(letters and numbers) and move a very long program in or out of the 
VIC*s memory in a fraction of a second. No long waiting for a tape 
drive to find, read and load a program. This device connects to the 
VIC'S serial port. 



IEEE-488 INTERFACE CARTRIDGE 

IEEE-488 is a universal scientific standard that iets you use 
Commodore PET/CBM peripherals such as disk drives and printers, 
as well as scientiftc instruments and tools. 



SERIAL PRINTER 

The VIC has a Serial Interface for peripherals which use serial 
connections to communicate with the computer. With Commodore's 
special dot matrix printer that uses this serial connection you can 
print your program listings and results on paper. 



107 



GAME PORT 



c- 
c 
c 



The VIC Game Port allows you to hook up joysticks, light pens, and (^ 

paddles, so that you can easily play exciting arcade type games 

without having to use the keyboard. (_ 

c 

TELECOMMUNICATIONS C 

You may have heard about programs that let your personal computer ( 
talk to other computers and get information about Ihe Stock Market, 

Business, News and other things — the VIC has this ability already C 

built in. ^ 

The VIC^s User Port includes an RS232 interface which lets you obtafn ^ 
Of exchange information over the telephone using an inexpensive 

telecommunications modem. Q 



SOFTWARE • 

In addition to all of this hardware, the VIC has a lot of interesting f 

software. > 

Some software programs are stored in hardware cartridges which 

plug in to the back of the VIC and are ready to run as soon as the ^ 

power is turned on. Some are on tape, some are on disk, and many ^ 

are included in the VIC Learning Series Book and cartridge sets which 

let you teach yourself computing and other subjects at home. ^ 

This has been just a short overview of accessories available to you. ( 

( 

KEEP IN TOUCH WITH YOUR ( 
COMMODORE DEALER TO FIND OUT 
ABOUT THE NEWEST DEVELOPMENTS! 



( 



108 



C 

c 
( 
( 

( 
c 
c 

c \ 



"APPENDIX B" 

USING THE CASSETTE RECORDER 

The cassette recorder acts as the VtC's "memory". Without this 
device, the VIC will forget any program you typed in as soon as the 
power goes off (or someone uses the NEW command). You can also 
use the recorder for programs you purchase. Commands used with 
programs on tape are SAVE, LOAD, and VERIFY. 

The VIC can also "remember'' the values of variables and other 
items of data, collected in a group called a file. The amount of data 
stored in a file can be very large compared to the amount of RAM in 
the VIC, because the VIC can operate on a small piece of the file at 
a time. Statements used with data files are OPEN, CLOSE, PRINTS, 
INPUT#, and GET#. The system variable ST (status), is used to 
check for tape markers. 

PROGRAM STORAGE 

Let's say you have just finished creating a new program on the VIC. 
You will want to use the program again at some other time, so now 
you must store it on the tape. Type the word SAVE. If you want the 
program to have a name, type a quote mark D and the program 
name. The name can contain graphics and cursor controls, and can 
be up to sixteen characters long. Then just hit the RETURN key, 
whether you gave it a name or not. 

If your recorder Is plugged into the back of the VIC, and none of its 
buttons are pressed down, the following message will appear on the 
screen: 

PRESS PLAY AND RECORD ON TAPE 

All you have to do now is put a blank cassette tape {any decent 
audio tape will do) in the recorder. Hold down the RECORD key and 
hit PLAY on the recorder. The tape should start moving, and the 
following message will appear on the screen: 
OK 

SAVING name 

What the VIC \s domg now is recording, with a very fast series of 
high and low sounds, your program in RAM onto the tape. The 
program is not being disturbed at all, it is just being copied. The 
VIC actually records the program twice, just in case your blank tape 
isn't perfect. V\/hen the program is al! on the tape, the VIC stops the 
recorder (all by itself!) and gives the READY message. 

Now you may wish to check the tape to make sure that the SAVEd 
program is correct. After all, you are risking much of your valuable 
time to an uncertain piece of thin magnetic tape. It is better to be 
sale and check the program. 



109 



FOUND name 



The command to check the tape is called VERIFY. First, rewind the 
tape back to the beginning. Now type the word VERIFY. If your 
program had a name, you may type a quote mark and the name. If 
you want to VERIFY the first program on the tape, you can just 
leave off the program name. Next just hit the RETURN key. 

Now, if none of the keys on the recorder are pressed, the VIC wHi 
tell you this: 

PRESS PLAY ON TAPE 

Be very sure that the RECORD button is NOT down when you do 
this. That would result in erasing any program or data that may have 
been on the tape. 

When you've pressed PL/^Y, this message appears: 

SEARCHING FOR name 

From this point on, the VIC will search for the program you have 

specified on the tape. If It finds any programs or data files, it will 9 

report the fact with the message: 

( 

If the name of the program matches, or at least matches as many r 

letters as you gave (which is why giving no name checks the first 

program), the next message Is; ^^ 

VERIFYING % 

When the program is completely read on the tape, the VIC gives you C ' 

the verdict. You may see the message: ^. 

OK ^^ 

READY. 

This means that the program on the tape was identical with the 
program you have in RAM currently. 

If the programs did not match, you'il see the message: 

7VERIFY ERROR 

READY, 

One of the extra uses of the VERIFY command is to position the 
tape right after the last program, so you can add a new program to 
the tape. Just VERIFY using the name of the last program on the 
tape. You will end up v^ith a VERIFY ERROR, but the tape will be 
right where you want it. Tricky, right? 



110 



Now let's say that you've come back to the VIC and you want to use 
that program you stored away. The command for this is LOAD. Type 
the word LOAD, and you can follow it with a program name 
(enclosed in quotes) if you like. The VIC says: 

PRESS PLAY ON TAPE 

You must press only the PLAY key on the recorder. The VtC will 
now say: 

SEARCHING FOR name 

Just as in VERIFY, the VIC lets you know of any programs or files 
encountered until the matching name. Then this message appears: 

FOUND name 

LOADING 

When the program is loaded, the VIC says: 

OK 

READY. 

Now the program is ready to be LISTed, RUN, or any other 
operation, just as if you had just typed it all in. 

PROGRAM 1: WRITE-TO-TAPE 

10 PRINT" ^^H ^B V\/RITE-TO-TAPE PROGRAM" 

20 OPEN 1,1.t,"DATA FILE" 

30 PR I NT" NOW TYPE DATA TO BE" 

40 PRfNT-STORED OR TYPE ^ ^^ STOP ^ ^^ 

50 PRINT 

60INPUr'DATA'^;A$ | 

70PRINT#1,A$ 

80 IFA$<>-STOP"THEN50 

90 PRINT 

\ 

100PRINT"CLOSING FILE" i 

I 

1 10 CLOSE 1 ^ 



111 



c 
c 
c 



c 
c 

PROGRAM 2: READ-TAPE USING INPUT# (^ 

10 PRINT" ^^9 ^ READ-TAPE PROGRAM" C 

20 OPEN 1,1,0, "DATA FILE" 

30 PRINT'TILE OPEN" 

40 PRINT 

50INPUT#1,A$ 

60 PRINT A$ 

70 IF AS = "STOP"THEN END 

80 GOTO 40 

PROGRAM 3: READ-TAPE USING GET# 

Lines 10 to 40 same as PROGRAM 2 

50GET#1,A$ ^ 

60 IF A$ = ""THEN END r 

70 PRINT A$,ASC(A$) ( 

80 GOTO 50 C 



c 



112 



r 

c 

( 
( 

c 
c 

C 



APPENDIX C: VIC BASIC 

This manual has given you an introduction to the BASIC language, 
just enough for you to get a feel for computer programming and some 
of the vocabulary involved. This appendix gives a complete list of the 
rules (SYNTAX) of the VIC BASIC language, along with a concise 
description of each. You are encouraged to experiment with these 
commands, remembering that you canH do any permanent damage to 
the VIC by just typing in programs, and that the best way to learn 
computing is by doing. 

This appendix is divided into sections according to the different types 
of operations in BASIC. These include: 

1. Variables and Operators: describes the different types of variables, 
legal variable names, and arithmetic and logical operators. 

2- Commands: describes the commands used to work with programs, 
edit, store, and erase them. 

3. Statements: describes the BASIC program statements used in 
numbered lines of programs. 

4. Functions: describes the string, numeric, and print functions. 

The commands in each section are listed alphabetically for conve- 
nience. A fuller explanation of VIC BASIC commands is provided in 
the VIC Programmer's Reference Guide, available where you bought 
your VIC. 

1. VARIABLES & OPERATORS 

a, VARIABLES 

The VIC uses three types of variables in BASIC. These are: normal 
numeric, integer numeric, and string (alphanumeric) variables. 

Normal numeric variables, also called floating point variables, can 
have any vatue from - 10'^ to + 10^, with up to nine digits of 
accuracy. When a number becomes larger than nine digits will show, 
as in 10^° or 10-^°, the computer will display it in scientific notation 
form, with the number normalized to 1 digit and eight decimal places, 
followed by the letter E and the power of ten by which the number is 
multiplied. For example, the number 12345578901 will be displayed as 
1,23456789E + ir 

Integer variables, are used when the number will always be between 
+ 32767 and -32768, and without fractional parts. Integer variables 
require less memory space than floating point variables, but the 
difference probably would not be substantial unless used in a large 
quantity such as an array (see below). An integer variable would be a 
number like 5, 10, or -100. 

String variables, are those used for character data, which may 
contain numbers, letters, and any other character that the VJC can 
make. An example of a string variable is ''VIC20/* 



113 



c 
c 

Variable names may consist of a single letter, a fetter followed by a f 
number, or two letters. ^ 

An integer variable Is specified by using the percent (%) sign after 
the variable name. String variables have the dotlar sign W after C 

their names. 



EXAMPLES: 

Numeric Variable Names: A, A5, BZ 
Integer Variable Names: A%, A5%, BZ% 
String Variable Names: A$, A5$, BZS 



c 
c 
c 
o 

Arrays, are lists of variables with the same name, using an extra 
number to specify which is which. They are defined using the DIM C 
statement, and may contain floating point, integer, or string ^ 

variables. The array variable name is followed by a set of " 

parentheses ( ) enclosing the number of the variable in the list. 



EXAMPLES: A(7>,BZ%(11),A$(a7). 



EXAMPLES: A(7,2),BZ%(2.3,4),Z$<3,2) 



Tl and TiS are variables which relate to the real-time clock built into 
the VIC. The variable Tl is updated every 1/60th of a second. It starts 



c 
c 



Arrays may have more than one dimension. A two dimensional array (^ 
may be viewed as having rows and columns, with the first number 
meaning which row and the second number in the parentheses mean- C 
ing which column. 



c 
c 



There are three variable names which are reserved for use by the VIC, ( 
and may not be used for a normal purpose. These are the variables 

ST, Tl, and Tl$. ST is a status variable which relates to input/output ( 
operations. The value of ST will change if there is a problem loading a 

program or data from the tape or disk. A more detaifed explanation of C 

ST is in the VIC BASIC Programmer's Reference Manual ^ 

( 



at when the VIC Is turned on, and is reset only by changing the ri 

value of TIS. ^' 

TIS is a string which Is constantly updated by the system. The first 

two characters contains the number of hours, the 3rd and 4th O 

characters are the number of minutes, and the 5th and 6th characters 

are the number of seconds. This variable can be given any value (so ^ 

long as all characters are nunnbers), and will be updated from that . 

point automatically. ^ 

EXAMPLE: TI$ = *'101530" sets the clock to 10:15 and 30 seconds (AM) C 

This clock is erased when the VfC is turned off, and starts at zero ( 

when the VIC is turned back on. 

c 

( 
c 

114 ^ 

c 



b, OPERATORS 

The arithmetic operators include the following signs: 

+ addition 

- subtraction 

* multiplication 

/ division 

T raising to power (exponentiation) 

On a line containing more than one operator, there fs a set order in 
which operations always occur. H several operators are used together, 
the computer assigns priorities as follows: First, exponentiation. 
Next, multiplication and division, and last, addition and subtraction. If 
you want these operations to occur in a different order, VIC BASIC 
allows you to isolate a calculation by putting 

parentheses around it. Operations enclosed in parentheses will take 
place before other operations. Be sure that your formulas have the 
same number of left parentheses (as right parentheses), or your 
program will get a SYNTAX ERROR message when run. 

There are also operators for equalities and inequalities: 

= is equal to 

< is less than 

> is greater than 

< = or = < is less than or equal to 

> = or ^ > is greater than or equal to 

< >or > < is not equal to 

Finally, there are three logical operators: 

AND 

OR 

NOT 

These are used most often to join multiple formulas th IF... THEN 
statements, 

EXAMPLE: 

IF A = BAND C = DTHEN 100 requires both A ^ B & C = D to be true. 

IFA = BORC = D THEN 100 Allows either A = B or C = D to be true. 

2. COMMANDS 

CO NT (Continue) 

This command is used to re-start the execution of a program which 
has been stopped by either using the STOP key, a STOP statement, or 
an END statement within the program. The program will re-start at the 
exact place from which it left off. 



115 



( 
( 

CONT will not work If you have changed or added lines of the program ( 
(or even just moved the cursor to a program line and hit RETURN 
without changing anything), or if the program halted due to an error, ( 
or if you caused an error before trying to re-start the program. The 
message in this case is CANT CONTINUE ERROR, 



LIST 



EXAMPLES: 

LIST Shows entire program. 

LIST 10— Shows only from line 10 untrl the end, 

LIST 10 Shows only line 10. 



c 



c 
c 



The LIST command allows you to look at lines of a BASIC program C 

that have been typed or LOADed into the VIC'S memory. When used 
alone without any numbers following it you will see a complete listing v 
ol the program on your screen (which may be slowed down by holding 
down the CTRL key or STOPped by hitting the key marked RUN 
STOP). If you follow the word LiST with a line number, the VIC will 
only show you that line number. If you type LJST with 2 numbers 
separated by a dash, the VIC will show all lines between the first and ( 
second line number, if you type LIST followed by a number and just a 
dash, it will show all the lines from that number to the end of the pro- C 
gram. And if you type LIST, a dash, and then a number, you will get all 
the lines from the beginning until that line number. Using these varia- v 
tions, you can examine any portion of a program, or bring lines to the 
screen for modification. 



c 



c 
( 

c 
( 

LIST— 10 Shows lines from the beginnmg untrf line 10. r 

LIST 10—20 Shows lines from 10 to 20, inclusive. ( 

LOAD abbrev. L sh O 

This is the command to use when you have a program stored on f 

cassette tape or on disk, and you want to use it- If you type just the ^ 

LOAD and hit the RETURN key, the VIC will find the first program on f 
the cassette tape and bring it into memory, to be RUN, LISTed, or 

whatever. You can also type the word LOAD followed by a program (' 
name, which is most often a name in quotes {'*'% The name may be 

foiiowed by a comma (outside of any quotes) and a number or C 
numeric variable, which acts as a device number to determine where 

the program is coming from. If there is no number given, the VIC f 

assumes device #1, which is the cassette tape recorder. ^ 

The other device commonly used with the LOAD command is the disk r 
drive, which is device #8. 



116 



c 

c 



EXAMPLES: 

LOAD Reads in the next program on tape 

LOAD "HELLO" Searches tape lor program called HELLO, and 
loads if found. 

LOAD A$ Looks for a program whose name is in the 

variable called A$. 

LOAD "HELL0'\8 Looks for the program called HELLO on the disk 
drive. 

LOAD"*'\8 Looks for the first program on the dtsk. 

The LOAD command can be used within a BASIC program to find and 
RUN the next program on a tape. 

NEW 

This command erases the entire program in memory, and also clears 
out any variables that may have been used. Unless the program was 
previously stored somewhere, it is lost until you type it in again. BE 
CAREFUL when you use this command! 

The NEW command can also be used as a statement in a BASIC pro- 
gram. When the VIC gets to this line, the program is erased and every- 
thing stops, it is useful if you want to leave everything neat when the 
program is done. 



RUN 

Once a program has been typed into memory or LOADed, the RUN 
command is used to make it start working. If there is no number 
following the command RUN, the computer will start with the lowest 
numbered program line. If there is a number, that becomes the line 
number where the program starts from. 

EXAMPLES: 

RUN Starts program working from lowest line number. 

RUN 100 Starts program at line 10O. 

RUN X UNDEFINED STATEMENT ERROR (you must always type 
RUN by itself or with a tine number - not wHh a letter). 

SAVE 

This command will store a program currently in memory on a cassette 
tape or disk. If you just type the word SAVE and hit return, the 
machine will attempt to store the program on the cassette tape. It has 

117 



no way of checking that there is already a program on that spot, so be 
careful with your tapes. If you type the SAVE command followed by a 
name in quotes or a string variable name, the VIC will give the pro- 
gram that name, so it may be more easily located and retrieved in the 
future. The name may be followed by a comma (after the quotes) and 
a number or numeric variable. This number tells the VIC which device 
on which to store the program. Devrce number 1 is the tape drfve, and 
#8 is the disk. After the number there can be a comma and a second 
number, which is either or 1. If the second number rs 1, the VIC will 
put an END-OFTAPE marker after your program. If you are trying to 
LOAD a program and the VIC finds one of these markers, you wril get ( 
a FILE NOT FOUND ERROR. 

c 

EXAMPLE: ^ 

m 

SAVE Stores program to tape without a name. ^ 

SAVE "HELLO" Stores on tape with the name HELLO. (^ 

SAVE A$ Stores on tape with name in variable AS. ^ 

SAVE "HELL0",8 Stores on disk with name HELLO C 

SAVE ^'HELL0"\1,1 Stores on tape with name HELLO and follows ^ 

program with an END-OF-TAPE marker. r- 

VERIFY ^ 

This command causes the VIC to check the program on tape or disk 

against the one m memory. This is proof that the program you just ( 

SAVEd is really saved, In case your tape is bad or something isn't ^ 

working. This command is also very useful for positioning a tape so ^ 

that the VfC will write after the last program on the tape. All you do is /-^ 

tell the ViC to VERIFY the name of the last program on the X^pe. It will ^ 

do so, and tell you that the programs don't match (whrch you already f 
knew). Now the tape is where you want it, and you can store the next 

program without any fear of erasing an old one. C 

VERIFY without anything after the command causes the VIC to check ( 
the next program on tape, regardless of its name, against the program 

now in memory. VERIFY followed by a program name (in quotes) or a ^ 

string variable will search the tape for that program and then check. r 
VERIFY followed by a name and a comma and a number will check 

the program on the device with that number (1 for tape, 8 for disk), f 

EXAMPLE: (^ 

VERIFY Checks the next program on the tape. ^ 

VERIFY '^HELLO" Searches for HELLO, checks against memory. ^ 

VERIFY "HELL0",8 Searches for HELLO on disk, then checks. ^ 

o 

118 # 

( 



3. STATEMENTS 

CLOSE 

This command completes and closes any files used by OPEN 
statements. The number following the word CLOSE is the file number 
to be closed. 

EXAMPLE: 

CLOSE 2 Only file #2 is closed. 



CLB 

This command wilf erase any variables in memory, but leaves the pro- 
gram itself intact. This command is automatically executed when a 
BUN command is given. 



CMD 

CMD sends the output which normally would go to the screen (i.e. 
PRINT statements, LISTS, but not POKEs into the screen) to another 
device instead. This could be a printer, or a data file on tape or disk. 
This device or file must be OPENed first. The CMD command must be 
followed by a number or numeric variable referring to the file. 

EXAMPLE: 

OPEN 1,4 OPENS device #4, which is the printer. 

CMD 1 All normal output now goes to the printer. 

LIST The USTing goes to the printer, not the screen— even the 

word LIST that you typed 1 

To start sending back to the screen normally, just CLOSE the file, 

DATA 

This statement is followed by a list of items to be used by READ 
statements. The items may be numbers or words, and are separated 
by commas. Words need not be inside of quote marks, unless they 
contain any of the following characters: SPACE, colon, of comma. If 
two commas have nothing between them, the value will be READ as a 
zero for a number, or an empty string. 

EXAMPLE OF A DATA STATEMENT: 

DATA 100,200,FRED,"HELLO, MOM".,3.14,abcl23 



119 



( 

( 

Since the program never needs to actually execute a DATA statement 
in order to read the information, it is a good idea to put your DATA V 

statements as close to the last line of the program as possible. This 
will help your programs run faster. 



DEF FN (Define Function) 



EXAMPLE 

10 DIM A$(40),B705) 
,41 Elements 




( 

o 



This command allows you to define a complex calculation as a func- 
tion with a short name. In the case of a long formula that is used C 
several times during a program, this can save lots of space. 



( 



The name you give the function will be the letters FN and any legal 

variable name(1 or 2 characters long). First you must define the func- 

tion by using the statement DEF followed by the name you have given f) 

the function. Following the name is a set of parentheses with a 

numeric variable (in this case X) enclosed. Then you have an equal f 

sign, followed by the formula you want to define. You can ^'call" the 

formula, substituting any numberforJ(^us1ng the format shown in line ( 

20 of the example below: CT'^y^^\^^^'^^^''^'^'''y^ 

^ Asterisk is used K ( 

EXAMPLE: j'^^^"''^ as multiplication J 

sign ,J C 

10 DEF FNA{X) = 12*(34.75-X/.3)^ 

The No. 7 is 

20 PRINT FNA(7)^L^ ===^ inserted where X S (; 

is in the fornnula \ 

c 

DIM (Dimension an array) r 

Before you get to use arrays of variables, unless there are 11 or fewer ( 

elements, the program must first execute a DIM statement for that 

array. The statement DIM is followed by the name of the array, which C 

may be any legal variable name. Then, enclosed in parentheses, you 

put the number (or numeric variable) of elements in each dimension. C 

An array with more than one dimension is called a matrix- You may ^ 

use any number of dimensions, but keep in mind that the whole list of ^ ' 

variables you are creating takes up lots of room, and it is easy to run r 

out of memory if you get carried away. To figure the number of 

variables created with each DIM, multiply the total number of % 

elements in each dimension of the array. 



c 

You can dimension more than one array in a DIM statement by (^ ' 
separating the arrays by commas. Be careful not to let the program 

execute a DIM statement for any array more than once, or you'll get C ' 

an error message. It is a good idea to keep DIMs near the beginning ^ 

of the program. C ' 

120 C 

c 



END 

When the program hits a line with the END statement, the program 
stops RUNning as if it ran out of lines. You may use the GONT com- 
mand to re-start the program. 



FOR..,TO...STEP 

This statement works with the NEXT statement to set up a section of 
the program that repeats for a set number of times. You may just 
want the VIC to count up to a large number so the program will pause 
for a few seconds, or you may need something counted. These are 
among the most commonly used statements in BASIC. 

The format of the statement is as follows: 

FOR (loop variable name) = {start of count) TO [end of count). The 
loop variable is a variable which will be added or subtracted to during 
the program. The start of count and end of count are the limits to the 
value of the loop variable. 

The logic of the FOR statement is as follows. First, the loop variable 
is set to the start of count value. The end of count value is saved for 
later reference by the VIC. When the program reaches a line with the 
command NEXT, it adds one to the value of the loop variable and 
checks to see if it is higher than the end of loop value. If it is not 
higher, the next line executed is the statement immediately following 
the FOR statement. If the loop variable is larger than the end of loop 
number, then the next statement executed will be the one following 
the NEXT statement. 

EXAMPLE: 

10 FOR L = 1 TO 10 

20 PRINT L 

30 NEXT L 

40 PRINT "I'M DONE! L = "L 

This program will print the numbers from one to ten on the screen, 
followed by the message I'M DONE! L= 11. Do you see why it works? 
If not, try re-reading the paragraph before the example again, and 
tracing through the program one step at a time on paper. 

The end of loop value may be followed by the word STEP and another 
number or variable. In this case, the value following the STEP is 
added each time instead of one. This allows you to count backwards, 
by fractions, or any way necessary. 



121 



You can set up foops inside one another. This is known as nesting 
ioops. You must be careful to nest ioops so that the later loop to start 
is the eariier one to end. 

EXAI^PLE OF NESTED LOOPS: 

10 FOR L = 1 TO 100 

20 FOR A = 5 TO 11 STEP 2 

30 NEXT A 

40 NEXT L 




Not correct 




10FORL = 


1 TO 100 


20 FOR A = 


5T0 11STEP2 


30 NEXT L 




40 NEXT A 





GET 

The GET statement Is a way to get data from the keyboard one 
character at a time. When the GET is executed, the character that was 
typed is received. If no character was typed, then a null (empty) 
character is received, and the program continues. There is no need to 
hit the RETURN key, and in fact the RETURN key can be received with 
a GET. 

The word GET is followed by a variable name, usually a string 
variable. If a numeric were used and any key other than a number was 
hit, the program would stop with an error message. The GET state- 
ment may also be put into a loop, ctiecking for an empty result, which 
will wait for a key to be struck. 



EXAMPLE: 
1QGETA$:IFA$==*'"THEN 10 



This line waits 
for a key to be 
struck. Typing any 
key will continue 
the progrann. 



c 
c 

c 

c 
c 
c 
c 

c 



122 



c 
c 

c 
( 

( 
( 
( 
( 
c 
( 
c 
( 
( 
( 
( 
( 
c 
( 
( 



GET# 

Used with a previously OPENed device or fiie to input one cliarcter at 
a time, 

EXAMPLE: 

GET#1,A$ 

Gosue 

This statement rs like the GOTO statement, except that the VfC 
remembers where it came from. When a line with a RETURN state- 
ment is encountered, the program jumps back to the statement im- 
mediately following the GOSUB. This is useful if there is a routine in 
your program that occurs several times in different parts of the pro- 
gram. Instead of typing the same over and over, you type it once and 
GOSUB to it from the different parts of the program. 20 GOSUB 800 
means go to the subroutine beginning at line 800 and execute it, 

GOTO or GO TO 

When a statement with the GOTO command is reached, the next line 
to be executed will be the one with the line number following the word 
GOTO. 



IF... THEN 

The IF.. .THEN statement lets your VIC analyze a situation and take 
two possible courses of action depending on the outcome. If the ex- 
pression being evaluated Is found to be true, the statement following 
the word THEN is executed^ This may be a line number, which will 
cause the VIC to GOTO that line of the program. It may also be any 
other BASIC statement or statements. If the expression is false, then 
the next line [not the next statement on the same line) is executed 
instead. 

The expression being evaluated may be a variable or formula, in whrch 
case it is considered true if non-zero, and false if zero. In most cases, 
there is an expression involving the refathnaf operators ( = , , , = , = , 
, AND, OR, NOT). If the result is found to be true, it has a value of — 1, 
and a value of if false. See the section on relational operators for an 
explanation of how this works. 



12i 



INPUT 



INPUT# 

This works like INPUT, but takes the data from a previously OPENed 
file or device. 



c 
c 
c 



The INPUT statement allows the computer to get data into a variable r 
from the person running the program. The program will stop, print 
a question mark (?) on the screen, and wait for the person to type the ( 
answer and hit the RETURN key. 



The work INPUT is followed by a variable name or list of variable 

names separated by commas. There may be a message inside of v 

quotes before the list of variables to be input. If this message (called 

a prompt) is present, there must be a semicolon (;) after the last quote 

of the prompt. When more than one variable is to be INPUT, they / 

should be separated by commas when typed in. 



EXAMPLE: 

10 INPUP'PLEASE TYPE A #":A , 

1 
20 INPUP'AND YOUR NAME^";A$ ^ 

30 INPUT B$ m 

40 PRINT'BET YOU DIDNT KNOW WHAT I WANTED!" ^ 

c 
( 

( 

( 

LET ( 

The word LET itself is hardly ever used in programs, since it is op- ( 
Itonal, but the statement is the heart of alJ BASIC programs. The 

variable name which is to get the result of a calculalton is on the left ( 

side of the equal sign, and the number or formula is on the right side. , 

EXAMPLE: ^ 

10 LET A = 5 ( 

20B = 6 ( 

30C = A*B + 3 ( 

40D$ = "HELLO'^ f 

( 

( 
( 
i 
( 
( 



124 



NEXT 

The NEXT statement is always used in conjunction with the FOR 
statement. When the program gets up to a NEXT statement, it goes 
back to the FOR statement and checks the loop. (See FOR statement 
for more detail.) If the loop is finished, execution proceeds with the 
statement after the NEXT statement. The word NEXT may be followed 
by a variable name, or a fist of variable names, separated by commas. 
If there are no names listed, the last loop started is the one being 
completed. If the variables are given, they are completed in order form 
left to right. 

EXAMPLE: 

10 FOR L = 1 TO10:NEXT 

20FORL = 1T010:NEXTL 

30FORL=1 TO10:FORM = 1 TO 10:NEXT M.L 

ON 

This command can make the GOTO and GOSUB commands into 
speciaf versions of the IF statement. The word ON is followed by a 
formula, which is evaluated into a number. The word GOTO or GOSUB 
is to I lowed by a list of line numbers separated by commas. If the 
result of the calculation is 1, the first line in the list is executed. If the 
result is 2, the second line number is executed, and so on. If the result 
is 0, negative, or larger than the list of line numbers, the next line 
executed will be the statement following the ON statements. 

EXAMPLE: 

10 INPUT X 

20 ON X GOTO 10,50,50,50 

30 PRINT ''NOPE!" 

40 GOTO 10 

50PRINT"YUPI" 

60 ON X GOTO 10,30,30 



1^ 



OPEN 



c 
c 
c 



c 
c 



The OPEN statement allows the VIC to access devices such as the 
cassette recorder and disk for data, a printer, or even the screen of 
the VIC. The word OPEN is followed by a number, which is the 
number to which all other BASIC statements will refer. This number is 
from 1 to 255. There is usually a second number after the first, 
separated by a comma. This is the device number, lor the VIC 
screen, 1 for the cassette recorder, 4 for the printer, 8 for the disk. It is 
a good idea to use the same reference number as the device number, 
which makes it easy to remember which is which. Following the 
second number may be a third number, separated again by a comma, 
which is the secondary address, in the case of the cassette, this may 
be for read, 1 for write, and 2 for write with end-of4ape marker at the (^ 
end- In the case of the disk, the number refers to the buffer, or chan- 
nel, number. In the printer, the secondary addresses become different C 
types of commands. See the VIC Programmers' Reference f^anual for 
more on these. There may also be a string following the third number, 
which would be a command to the disk drive or the name of the file 
on tape. 

EXAMPLE: 

10 OPEN 1,0 OPENS the SCREEN as a device, 

20 OPEN 2,1,0/'D*' OPENS the cassette for reading, file to be 
searched for Is named D. 

30 OPEN 3,4 To use the printer. 

40 OPEN 4,8,15 OPENs the data channel on the disk. 

See also: CLOSE, CMD, GET#, INPUT#. and PRINT# statements, 
system variable ST, and Appendix B. 



POKE 

The POKE command is always followed by two numbers, or formulas- 
The first number is a location inside the VIC*s memory. There could 
be locations numbered from to over 65000. Some of these, like the 
ones described in the chapters on sound and colors, can be used 
easily in your programs. Some, however, are used by the VIC itself, 
to keep track of your programs and so on. Experimenting with the 
POKE statement will probably result in some interesting effects. If 
something happens and you can't stop it, just turn the VIC off and on 
again, or hold down the RUN/STOP key and hit RESTORE. 



126 



The second number is a value from to 255, which will be placed m 
the memory iocation, replacing any value that was there previously. 

EXAMPLE; 

10 POKE 36879,8 

20 POKE 9*16! 3 + 15,27 

PRINT 

The PRINT statement is the first one most people learn to use, but 
there are lots of subtleties to be mastered here as welL The word print 
can be followed by any of the following things: 

Words inside of quotes 
Variable names 
Functions 
Punctuation marks 

The words inside of quotes are often called literals because they are 
printed literally as they are typed in. Variable names outside of quotes 
will have the value they contain printed. Functions will have their 
values printed also. Punctuation marks are used to help forn^at the 
data neatly on the screen. The comma is used to divide the screen in- 
to 2 columns, while the semicolon doesn't leave any space at all. 
Either mark can be used as the last symbol in the statement. This 
results in the next thing PRINTed coming out as if it were continuing 
the same PRINT statement. 

EXAMPLE: 

10 PRINT "HELLO" 

20 PRINT "HELLO, "A$ 

30 PRINT A + B; 

50 PRINT J; 

60 PRINT A,B.C,D 

See also: POS( ), SPC( ), TAB( ) functions. 

PRINTS 

There are a few differences between this statement and the PRINT. 
First of all, the word PRINTS is followed by a number, which refers to 
the device or data file previously OPENed. The number is followed by 
a comma, and a list of things to be PRINTed. The comma and 
semicolon have the same effect on adding spaces as they do in the 
PRINT, but some devices may not work with TAB and SPG. 



127 



EXAMPLE: 

100 PRINT#i;^HELLO THERE! ";A$,B$ 

READ 

This statement is used to get information from DATA statements into 
variables, where they may be used. Care must be taken to avoid 
reading strings where the READ statement wants a number, which 
will give you a TYPE MISMATCH ERROR. 



REM (remark) 

The REMark is just a note to whoever is reading a LIST of the pro- 
gram. It may explain a section of the program, give information about 
the author, etc. REM statements in no way effect the operation of the 
program, except to add to its fength. The word REM may be followed 
by any text, although use of graphic characters will give strange 
results (see the VIC PROGRAMMER'S REFERENCE GUIDE for 
more info.) 



RESTORE 



When executed in a program, the pointer to which item in a DATA '- 

statement will be read next is reset to the first item in the list- This / 
gives you the ability to re-READ the information. The word RESTORE 

stands by itself on the line. ( 



RETURN 



STOP 

This statement will halt the program. A message, BREAK ERROR IN 
LINE xxxx, where xxxx is the fine number containing the STOP. The 
program can be re-started by using the CONT command. The STOP 
statement is used fof debugging a program. 

SYS 



This statement is always used in conjunction with the GOSUB state- 
ment. When the program hits a RETURN statement, it will go to the 
statement irr.mediately following the GOSUB command. If no GOSUB 
was previously issued, there is a RETURN WITHOUT GOSUB ERROR, 
There is nothing foflowing the word RETURN. ( 



( 

c 
( 
o 



c 
c 
c 

( 
c 

(. 



The word SYS Is followed by a decimaf number or numeric variable in 
the range 0-65535, The program will at this point begin executing the 
machine language program starting at that memory location. This is Q» 

similar to the USR function, but does not allow parameter passing. 

c > 



128 



WAIT 

The WAIT statement is used to halt the program until the contents of 
a location in memory changes in a specific way. The word WAIT rs 
followed by a number, which is the memory address being checked. 
Then comes a comma, and another number. There may be another 
comma and a third number as well. These last two numbers must be 
within the range 0-255, 

The contents of the memory location are first exclusive-ORed with the 
third number, if present, and then logically ANDed with the second 
number. If the result is zero, the program goes back to that memory 
location and checks again. When the result is non-zero, the program 
continues with the next statement. 



4- FUNCTIONS 
a. NUMERIC 

AB5(X) (absolute value) 

The absolute value returns the value of the number, without It's sign 
( - or +). The answer is always positive. 

ATN(X) (arctangent) 

Returns the angle, measured in radtans, whose tangent is X. 

COS(X) (cosine) 

Returns the value of the cosine of X, where X is an angle measured in 
radians. 

EXP(XJ 

Returns the value of the mathematical constant e (2 J1827183) raised 
to the power of X. 

FNXX(X) 

Returns the value of the user-defined function XX created in a DEF 
FNXX statement. 

mT(X) (Integer) 

Returns the truncated value of X, that is, with all decimal places to 
the right of the decimal point removed. The result will always be less- 
than or equal-to X. Thus, any negative numbers with decimal places 
will become the integer less-than their current value. 

129 



If the INT function is to be used for rounding up or down, the form is 
INT(X + .5). 

EXAMPLE: 

X = INT(X'100 + .5)/100 Rounds to the nearest penny. 

LOG(X) (logarithm) 

This will return the natural log of X. The natural log is log to the base 
e (see EXP(X)). To convert to log base 10, simply divtde by LOG(IO), 

PEEK{X) 

Thfs is used for finding out the contents ol memory location X, in the 
range of 0-65535, giving a result from 0-255, This is often used in con- 
junction with the POKE statement. 

c 

RND(X) (random number) A 

This function will return a random (or nearly so) number between Q 

and 1. This is useful in games, to simulate dice rolls and other 
elements of chance, and is also used in some statistical applications. C 
The first random number should be generated by the formula RND(-TI), 
to start things off differently every time. After this, the number in X 
should be a 1, or any positive number. If X is zero, the result will be 
the same random number as the iast one. A negative value for X will 
re-seed the generator. The use of the same negative number for X will 
result in the same sequence of "random" numbers. 

To simulate the rolling of a die, use the formula INT(BND(1)*6+ 1). 

First the random number from 0-1 is multiplied by 6, which expands 

the range to 6 {actually, greater than zero and less then six). Then 1 

is added, making the range 1-under 7. The INT function chops off all 

the decimal places, leaving the result as a digit from 1 to 6. ^ 

To simulate 2 dice, add two of the numbers obtained by the above r 

formula together. ^ 

e 
( 
( 
c 

100X+INT{RND(1)*150) + 100 Number from 100-249. (- 



EXAMPLE: 

100X = [NT(RND(ir6) + INT(flND(1)'6> + 2 Simulate 2 dice. 

100 X = INT(RND(1)* 1000) + 1 Number from 1-1000. 



SGN(X) (sign) 



c 
c 

This function returns ttie sign, as in positive, negative, or zero, of X. ^ 

The result will be -t- 1 if positive, if zero, and - 1 if negative. O 

130 ^ 

c 



SIN(X» (sine) 

This is the trigonometric sine function. The result will be the sine of X, 
where X is an angle in radians. 



SQR(X) (square root) 

This function will return the square root of X, where X is a positive 
number or 0. If X is negative, an ILLEGAL QUANTITY ERROR results. 



TAN (X) (tangent) 

The result will be the tangent of X, where X is an angle in radians. 

USR (X) 

When this function is used, the program jumps to a machine 
language program whose starting point is contained in memory loca- 
tions 1 and 2. The parameter X is passed to the machine language 
program, which will return another number back to the BASIC pro- 
gram. See the VIC PROGRAMMER'S REFERENCE MANUAL for more 
details on this, and on machine language programming. 

b, STRING FUNCTiONS 

ASC(X$) 

This function will return the ASCII code of the first character of X$. 

CHR$(X) 

This is the opposite of ASC, and returns a string character whose 
ASCII code isX, 

LEFT$(X$.X) 

This will return a string containing the leftmost X characters of X$. 

LEN(X$) 

Returned will be the number of characters (including spaces and 
other symbols) in the strrng X$. 

MID$(X$,S»X) 

This will return a string containing X characters, starting from the Sth 
character in XS. 

131 



RIGHTS(XS,X) 

Thfs will return the rightmost X characters m X$. 

STR$(X) 

This will contain a string which is identical to the PRINTed version of 

VAL(X$) 

This function converts the string X$ into a number, and is essentially 
the inverse operation from STR$. The string Is examined from the left- 
most character to the right, for as many characters as are in 
recognizable number format. If the VIC finds illegal characters, only 
the portion of the string up to that point is converted. 

EXAfVfPLE: 

10 X = VALC'123.456"') X = 123.456 

10X = VALr 12A13B'0 X = 12 

10X = VALrRIUO17*'l X = 

10 X = VAL('' - 1,23.23.23") X = ^ 1,23 

c. OTHER FUNCTIONS 
FRE{X) 

This function returns the number of unused bytes avaflable in 
memory, regardless of the value of X. 

POS(X) 

This function returns the number of the column (0-21) at which the 
next PRINT statement will begin on the screen. X may have any value 
and is not used. 



f 

( 
c 

t 



SPC(X) 

This is used in the PRINT statement to skip X spaces forward. 

TAB(X) # 

This is used in the PRiNT statement. The next item to be printed will 

be in column number X. ( 

132 # 

c 



APPENDIX D: 

ABBREVIATIONS FOR BASIC KEYWORDS 

As a time saver when typing in programs and commands, VIC BASIC 
allows the user to abbreviate most keywords. The abbreviation tor the 
word PRINT is a question mark. The abbreviations for the other words 
are made by typing the first one or two letters of the key word, 
followed by the SHIFTed next letter of the word. If the abbreviations 
are used in a program line, the keyword will LIST In the longer form. 
Note that some of the keywords when abbreviated include the first 
parenthesis, and others do not. 







Looks iiko 






Looks like 


Commind 


Abbreviation 


thb on $cr«en 


Command 


Abhrsflillon 


thb on $ci*cn 


AND 


A ^m N 


A 


/ 


f^RlNT* 


p ^^1 R 


P — 


NOT 


N ^^^1 


N 




READ 


R ^^^ E 


R 


CLOSE 


GL l^^l 


CL 




RESTORE 


RE^^^ S 


-¥ 


CLR 


G ^^1 L 


C 




RETURN 


RE ^^1 T 


RE 1 


CMO 


C ^^^ M 


c 


N 


RUN 


R ^^^: U 


^ r 


CONT 


c ^^^^^1 O 


c 




SAVE 


^^^H A 


s ♦ 


DATA 


D ^^1 A 


D 


♦ 


STEP 


ST ^^^ E 


ST| 


DEF 


^^^ E 


D 




STOP 


^^^1 T 


s 


DIM 


D ^^^1^ 1 


D 


^ 


SYS 


s ^^1 V 


s 


Eh/D 


E ^3B ^ 


E 


\/\ 


THEN 


T ^^^ H 


T 


FOR 


F ,^^^1 


F 




VERIFY 


V ^^n E 


V 


G€T 


G ^^^1 E 


G 


^ 


WAIT 


W ^^^ A 


w 4 


GOSUS 


GO^^I S 


GO ^ 


ABS 


^^^H 8 


A 


GOTO 


G 1^01 ^ 


G 




Ase 


A ^^^1 S 


- ¥ 


INPUTi 


1 ^^^N 


i 





ATN 


A ^^^^1 T 


A 


LET 


L ^^1 E 


I 




C^Rt 


C ^^^^^1 H 


C 


UST 


L ^^|l 


L 


^ 


EXP 


E ^^Hx 


. ♦ 


LOAD 


L ^^1 


L 




^m 


^^^H R 


F 


NEXT 


N H^l E 


N 




LEFTS 


LE ^^^ F 


LE 


OPEN 


^^^1 P 





n 


mm 


M ^9B 1 


M ^ 


POKE 


p ^^^ 


P 




PEEK 


^^^H E 


P 


PRINT 


? 


? 




RIGHTS 


R ^^^p 1 


" ^ 



133 







Looks llkt 






looiia Ilka I 


Com mind 


Abbr«tIitton 


this Ofi icretn 


Commtnd 


Abbrtrvlillon 


this on scr««ri 


RMD 


H M|n isr 


-^0 


STRS 


SI ^^1 R 




SGN 


S ^^^^1 G 


^D 


tAB( 


T ^^1 f^ 


'♦c 


SIN 


^^^H \ 


s a 


im 


u ^^^S 


"*. 


SPC( 


5 I^B^ 


sD 


VAL 


V ^^^1 A 


'♦( 


SQR 


S ^^^H Q 


s • 






^ 



APPENDIX E 
SCREEN & BORDER COLOR COMBINATIONS 

You can change the screen and border colors of the VIC anytime, in or 
out of a program, by typing 

POKE 36879, X 

where X is one of the numbers shown in the chart below. POKE 35879, 
27 returns the screen to the normal color combination, which is a 
CYAN border and white screen. 



CTRL 



f 



and you 



Try typing POKE 36879, 8. Then type 

have white letters on a totally black screen! Try some other 
combinations. This POKE command Is a quick and easy way to 
change screen colors in a program. 



c 
c 

• 

c 

f 

c 

( 

( 

( 













BORDER 








( 




SCREEN 


BLK 


WHT 


RED 


CYAN 


PUR 


GRN 


BLU 


YEL 




BLACK 


8 


9 


10 


11 


12 


13 


14 


15 


C 




WHITE 


24 


25 


26 


27 


28 


29 


30 


31 








RED 


40 


41 


42 


43 


44 


45 


46 


47 




CYAN 


56 


57 


58 


59 


60 


61 


62 


63 




PURPLE 


72 


73 


74 


75 


76 


77 


78 


79 






GREEN 


88 


89 


90 


91 


92 


93 


94 


95 




BLUE 


104 


105 


106 


107 


108 


109 


110 


111 




YELLOW 


120 


121 


122 


123 


124 


125 


126 


127 






ORANGE 


138 


137 


138 


139 


140 


141 


142 


143 




LT ORANGE 


152 


153 


154 


155 


156 


157 


158 


159 






PINK 


168 


169 


170 


171 


172 


173 


174 
190 


175 
191 






LT. CYAN 


184 


165 


186 


187 


188 


189 






LT. PURPLE 


200 


201 


202 


203 


204 


205 


206 


207 






LT GREEN 
LT. BLUE 


216 


217 


218 


219 


220 


221 


222 


223 






232 


233 


234 


235 


236 


237 


238 


239 






LT YELLOW 


24S 


249 


250 


251 


252 


253 


254 


255 












134 















APPENDIX F 
TABLE OF MUSICAL NOTES 



APPROX. 




APPROX. 




NOTE 


VALUE 


NOTE 


VALUE 


C 


135 


G 


215 


C# 


143 


G# 


217 


D 


147 


A 


219 


D# 


151 


A# 


221 


E 


159 


fi 


223 


F 


163 


e 


225 


F# 


167 


e# 


227 


G 


175 


D 


228 


G# 


179 


m 


229 


A 


183 


E 


231 


A# 


187 


F 


232 


B 


191 


F# 


233 


C 


195 


e 


235 


C# 


199 


m 


236 


D 


201 


A 


237 


D# 


203 


M 


238 


E 


207 


B 


239 


F 


209 


c 


240 


F# 


212 


c# 


241 


SPEAKER COMMANDS: 


WHERE X CAN BE: 


FUNCTION: 


POKE 36878. X 




0to15 


sets volume 


POKE 36874, X 




128 to 255 


plays tone 


POKE 36875, X 




128 to 255 


plays tone 


POKE 36876, X 




128 to 255 


plays tone 


POKE 36877, X 




128 to 255 


plays "noise" 



APPENDIX G: 

20 SOUND EFFECTS FOR THE VIC-20 

Here are some sample routines to use as a guide for creating sounds 
to enhance your programs. You may type them into your VIC -20 either 
by themselves or inside other programs. Of course, these are not 
nearly all of the possible sounds that your VIC-20 can play, so feel 
free to use your creativity. 

The sound effects listed here will make a program pause for however 
long they take to be completed. It is possible to put these effects into 
a program in a way that does not stop whatever animation may be 
running, and this topic is discussed in detail in the ViC'20 
Programmer's Reference Manual. 



135 



C 



Remember to use line numbers when you type these routines into the 
computer. The numbers are not shown here in order to avoid 
confusion when you enter them into your programs. 



i 
( 



#1: SCALES 


#5: RED ALERT 


». 


POKE 36878,15 


POKE 36878,15 


r 


FOR L= 250 TO 200 STEP -2 


FORL-1TO10 


( 


POKE 36876,1 


FOR M = 180 TO 235 STEP 2 


FORM = 1TO100 


POKE 36876,M 


( 


NEXTM 


FOR N = 1 TO 10 


NEXTL 


NEXTN 


( 


FOR L = 205 TO 250 STEP 2 


NEXTM 


%. 


POKE 36876,L 


POKE 36876,0 


c 


FOR M = 1 TO 100 


FORM = 1TO100 




NEXTM 


NEXTM 


• 


NEXTL 


NEXTL 


• 


POKE 36876,0 


POKE 36878,0 


POKE 36878,0 




i 




#6: LASER BEAM 


#2: COMPUTER MANIA 


POKE 36878,15 


• 


POKE 36878,15 


FORL=1TO30 


iC) 


F0RL=1 TO 100 


FOR M = 250 TO 240 STEP - 


POKE 36876,INT(RND(1)-128) + 128 


POKE 36876,M 


I 


FORM = 110 10 


NEXTM 


NEXTM 


FORM =240 TO 250 


( 


NEXTL 


POKE 36876,M 


v 


POKE 36876,0 


NEXTM 


{ 


POKE 36878,0 


POKE 36876,0 


f 




NEXTL 


i 


#3; EXPLOSION 


POKE 36878,0 


c 
( 


POKE 36877,220 

FORL = 15TO0STEP -1 


#7: HIGH-LOW SIREN 


POKE 36878, L 


POKE 36878,15 


• 


FOR M = 1 TO 300 


F0RL=1 TO 10 


NEXTM 


POKE 36875,200 


• 


NEXTL 


FOR M = 1 TO 500 


POKE 36877,0 


NEXTM 


• 


POKE 36878,0 


POKE 36875.0 




POKE 36876.200 


# 


#4: BOMBS AWAY 


FOR M = 1 TO 500 




POKE 36878,10 

FORL = 230TO128STEP -1 


NEXTM 
POKE 36876.0 
NEXT L 




POKE 36876,L 
FOR M = 1 TO 20 


POKE 36878,0 




NEXTM 






NEXT L 






POKE 36876,0 






POKE 36877,200 




FOR L= 15 TOO STEP -.05 






POKE 35878, L 




NEXTL 






POKE 36877,0 






136 







#8: BUSY SIGNAL 

POKE 36878,15 
F0RL=1T0 15 
POKE 36876,160 
FORM-1 TO 400 
NEXTM 
POKE 36876,0 
F0RM = 1 TO 400 
NEXTM 
NEXTL 
POKE 36878,0 

#9: PHONE RINGING 

POKE 36878,15 

F0RL = 1 TO 5 

FOR M = 1 TO 50 

POKE 36876,220 

FOR N = 1 TO 5 

NEXT N 

POKE 36876,0 

NEXTM 

FOR M = 1 TO 3000 

NEXTM 

NEXTL 

POKE 36878,0 

#10: BIRDS CHIRPING 



#12: OCEAN WAVES 

POKE 36877,180 

FOR L^1 TO 10 

D = INT{RND(1)*5)'50 + 50 

FOR M = 3 TO 15 

POKE 36878, M 

FOR N = 1 TO D 

NEXTN 

NEXTM 

FORM = 15 TO 3 STEP -1 

POKE 36878, M 

FOR N = 1 TO D 

NEXTN 

NEXTM 

NEXTL 

POKE 36878,0 

POKE 36877,0 

#13: VANISHING UFO 

POKE 36878,15 
FOR L= 130 TO 254 
POKE 36876,L 
FOR M = 1 TO 40 
NEXTM 
NEXTL 
POKE 36878,0 
POKE 36876,0 



POKE 36878,15 

FOR L = 1 TO 20 

FOR M = 254 TO 240 + INT (RND(I)MO) STEP - 1 

POKE36876,M 

NEXTM 

POKE 36876,0 

FOR M ==0 TO INT(RND(1)*100) + 120 

NEXTM 

NEXTL 



#11: WIND 

POKE 36878,15 
POKE 36874.170 
POKE 36877.240 
FOR L = 1 TO 2000 
NEXT L 
POKE 36874,0 
POKE 36877,0 
POKE 36878,0 



#14: UFO LANDING 

POKE 36878,15 

FOR L=1 TO20 

FOR M = 220L TO 160-L STEP - 4 

POKE 36876, M 

NEXTM 

FOR M = 160-L TO 220^1 STEP 4 

POK£36876,M 

NEXT M 

NEXT L 

POKE 36878,0 

POKE 36876,0 



137 



#15: UFO SHOOTING 


#19: DOOR OPEN [NG 




POKE 36878,15 


POKE 36878,15 




F0RL=1 T015 


B = 


FORM = 200TO220 + L*2 


FORL=:128T0 255STEP11 




POKE 36876,M 


POKE 36874,L 


NEXTM 


FOR M-1 TO 10 




NEXTL 


NEXTM 


POKE 36878,0 


B-B + 1 




POKE 36876,0 


IF B = 3 THEN B = 0: POKE 36874,0 






NEXTL 




#16: WOLF WHISTLE 


POKE 36874,0 






POKE 36878,0 




POKE 36878,15 






FOR L = 148 TO 220 STEP .7 


#20: BLIPS 




POKE 36876,L 




• 


NEXT L 


POKE 36878,15 


FOR L= 128 TO 200 


POKE 36876,220 




POKE 36876X 


F0RL = 1T0 5 


NEXTL 


NEXTL 




FOR L = 200 TO 128 STEP - 1 


POKE 36876,0 


POKE 36876.L 


FORL = 1TO500 




NEXTL 


NEXTL 




POKE 36878,0 


POKE 36876,200 




POKE 36876.0 


FOR L^l T0 5 






NEXTL 




#17: RUNNING FEET 


POKE 36876,0 






FOR L = 1 TO 500 


POKE 36878.15 


NEXTL 




FOR L=^1 TO 10 


POKE 36878,0 




POKE 36874,200 






FORM-1 TO 10 




NEXTM 






POKE 36874,0 




FOR M = 1 TO 100 






NEXTM 




NEXTL 






POKE 36878,0 




t 


#18: TICK-TOOK 




POKE 36878,15 




FORL = 1TO10 






POKE 36875,200 






FOR M = 1 TO 10 






NEXTM 






POKE 36875.0 






FOR M = 1 TO 300 






NEXTM 




POKE 36874,200 






FOR M = 1 TO 10 




NEXT M 






POKE 36874,0 






FOR M = 1 TO 300 






NEXT M 






NEXTL 






POKE 36878.0 




j^ 



138 



( 
( 

{ APPENDIX H: SCREEN DISPLAY CODES 

( The following chart lists all of the characters built-in to the VIC20 

character sets. They show which numbers should be POKEd into 

^ screen memory {locations 7680 to 8185) to get a desired character. 

/ Also, it shows what character corresponds to a number PEEKed from 

the screen. 

The two character sets are available, but only one set at a time. This 
( means that you cannot have characters from one set on the screen at 

the same time you have characters from the other set displayed. The 
( sets are switched by holding down the SHIFT and COMMODORE keys 

simuftaneously. This actually changes the 2 bit in memory location 

36869, which means that the statement 

POKE 36869, 240 will set the character set to upper case, and POKE 

36869, 242 switches to lower case. 



If you want to do some serious animation, you will find that It Is 
( easier to control objects on the screen by POKEing them into screen 

memory (and erasing them by poking a 32, which is the code for a 
( blank space, into the same memory location), than by PRINTing to the 

screen by using cursor control characters. 



Any number shown on the chart may also be displayed in REVERSE. 
Reverse characters are not shown, but the reverse of any character 



( may be obtained by adding 128 to the numbers shown. 

( NOTE: SEE SCREEN MEMORY MAP APPENDIX. 

( H you want to display a heart at screen location 7800, find the number 

of the character you want to display there (in this case a heart) in this 

( chart. ..the number for the heart is S3. ..then type in a POKE statement 

with the number of the screen location (7800) and the number of the 
symbol (83) like this: 



POKE 7800, 83 



( 

A white heart should appear in the middle area of the screen. Note 
( that it will be invisible if the screen is white. Try changing the position 

by changing the larger number, or type in different symbols ustng the 
( numbers from the chart. 

' If you want to change the COLOR of the symbol being displayed, 

/ consult the accompanying chart which lists the COLOR NUMBERS 

^ for EACH MEMORY LOCATION. In other words, to get a different 

( colored symbol at a particular location, this requires another POKE 

command. 

c 

( 
{ 
( 

^ 139 



For example, to get a red heart, type the following: 

POKE 38520, 2 




c 
c 

This changes the color of the symbol at location 7800 to red. If you Q 

had a different symbol Ihere^ that symbol would now be red. Yoif can 
display any character In any of the available colors by combining Q 

these two charts. These POKE commands can be added in your 
programs and are very effective especially in animation — and afso O 

provide a means to PEEK at certain locations if you are doing 
sophisticated programming such as bouncing a ball, which requires 
this inforrriation. 



140 

c 



/ 



( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
( 

c 

( 
( 

( 
( 
( 
( 
( 
( 
{ 
( 
( 
( 
( 



SCREEN CODES 



SET 1 SET 2 POKE 

@ 



A 

B 

C 

D 

E 

F 

G 

H 

I 

J 

K 

L 

M 

N 

O 

P 

Q 

R 

S 

T 



a 
b 
c 
d 
e 
f 
g 

h 
i 

i 

k 
I 

m 
n 
o 

P 

q 

r 
s 

t 



1 

2 

3 

4 

5 

6 

7 

8 

9 

10 

11 

12 

13 

14 

15 

16 

17 

18 

19 

20 



SET1 SET 2 POKE 

U u 21 



V 

w 

X 
Y 

z 

I 
s. 



# 
$ 
% 
& 



V 

w 

X 

y 

z 



22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 



SET1 SET 2 POKE 


* 


42 


+ 


43 


J 


44 


— 


45 




46 


1 


47 





48 


1 


49 


2 


50 


3 


51 


4 


52 


5 


53 


6 


54 


7 


55 


8 


56 


9 


57 


: 


58 


t 


59 


C 


60 


= 


61 


> 


62 



141 



SETl SET 2 POKE 


SET1 


SET 2 POKE 


SETl 


SET 2 POKE 


? 




63 


1 i 


T 


84 


1 


106 


— 




64 


1 


U 


85 


h 


107 


'^' 


A 


65 


IX 


V 


86 


y 


108 




B 


66 


a 


w 


87 


X 


109 


— ■ 


C 


67 


'♦ 


X 


88 


1 


110 




D 


68 




Y 


89 


^' 


111 


^^ 


E 


69 


♦1 


z 


90 


H 


112 




F 


70 


-t- 




91 


X 


113 




G 


71 


r 




92 


T 


114 




H 


72 






93 


rl 


115 


■> 


1 


73 


TT 


!!:: 


94 


1 


116 


V 


J 


74 


5 


ss 


95 


1 


117 


J 


K 


75 


^g 


96 


J 


118 


U 


L 


76 


C 




97 


P 


119 


\ 


M 


77 


y 




98 


1 


120 


i/^ 


N 


78 


n 




99 


u 


121 







79 






100 


J 


\/ 122 


n 


P 


80 


1 




101 


kJ 


123 


m' 


Q 


81 


iM 




102 


n 


124 




R 


82 






103 


M 1 


125 


¥ 


S 


83 


^ 




104 


n 


126 








n 


•Si 


105 


N 


127 



142 



APPENDIX I: SCREEN MEMORY MAPS 

Use this appendix to find the memory location of any position on the 
screen. Just find the position in tlie grid and add the numbers on the 
row and column together. For example, if you want to poke the 
graphic "ball" character onto the center of the screen, add the 
numbers at the edge of row 11 and column 11 (7900 + 10) for a total of 
7910. If you poke the code for a ball (81, see Appendix H) Into location 
7910 by typing POKE 7910,81, a white ball appears on the screen. To 
change the color of the ball (or other character), find the correspond- 
ing position on the color codes memory map, add the row and column 
numbers together (38620 + 10, or 38630) for the color code and type a 
second poke statement. For example, if you poke a color code into 
this location, POKE 38630,3 the bait will change color to cyan. Note 
that when POKEing, the character color numbers are one less than 
the numbers on the color keys— as shown below. 



Abbreviated List of Color Codes 


Code 


Color 





Black 


1 


White 


2 


Red 


3 


Cyan 


4 


Purple 


5 


Green 


6 


Blue 


7 


Yellow 



143 








1 


2 


3 


4 


5 


6 


7 


8 


g 


10 11 1213 14 15 16 17 18 19 20 21 


7680 














































7702 














































7724 






















; 
























7746 














































7768 


,_, 












































7790 












































7B12 












































7834 














































7856 














































7878 












































— 


7900 








































7922 


-, 












































7944 












































7966 












































7988 














































8010 














































8032 














































8054 














































8076 














































8098 














































8120 














































8142 














































8164 















































PAGE 1: SCREEN CHARACTER CODES 








1 


2 


3 


4 


5 


6 


7 


a 


9 


10 11 


12 13 14 15 16 17 18 19 20 21 


38400 














































38422 














































38444 














































38466 














































38488 














































38510 














































38532 














































38554 














































36576 












































38598 














































38620 














































386-^2 














































38664 ^ 












































— 


38686 












































38708 












































— 


38730 












































38752 














































38774 














































38796 














































38818 














































38840 














































38862 














































38884 [ 


, 


, 




__, 


^ 


_ 














1 1 


[ I 









PAGE 2: COLOR CODES MEMORY MAP 



144 



APPENDIX J: ASCII AND CHR$ CODES 

This appendix shows you wiiat characters will appear if you 
PRINT CHRS (X), for all possible values of X. It will also show the 
values obtained by typing PRINT ASC ("x'^) where x is any character 
you can type. This is useful in evaluating the character received in a 
GET statement, converting upper/fower case, and printing character- 
based commands {like switch to upper/lower case) that could not be 
enclosed in quotes. 



PRINTS CHRS 


PRINTS 


CHRS 


PRINTS ( 


:hr$ 


PRINTS 


CHRS 







16 


^B 


32 





48 


1 


Rffl 


17 


! 


33 


1 


49 


2 


mSSm 


18 


ii. 


34 


2 


50 


3 


UJJJg 


19 


# 


35 


3 


51 


4 


s 


20 


$ 


36 


4 


52 


^^^ 5 




21 


% 


37 


5 


53 


6 




22 


& 


38 


6 


54 


7 




23 




39 


7 


55 


8 




24 


( 


40 


8 


56 


9 




25 


) 


41 


9 


57 


10 




26 


* 


42 




58 


11 




27 


+ 


43 


t 


59 


12 


ISffil 


28 


, 


44 


<C 


60 


^^^^^1 13 


@ 

^^3 
^^1 


29 
30 
31 


/ 


45 

46 
47 




61 


■ SWITCH TO BRI 

■ LOWER CASE ■£■ 


62 


15 


63 



145 



PRINTS 


CHRS 


PRINTS 


CHRS 


PRINTS CHRS 


PRINTS CHRS 




@ 


64 


U 


85 


V. 


106 


n 127 




A 


65 


V 


86 


J 


107 


128 




B 


66 


W 


87 


u 


108 


129 




C 


67 


X 


88 


\ 


109 


130 




D 


68 


Y 


89 


H 


110 


131 




E 


69 


Z 


90 


n 


111 


132 


c 


F 


70 


[ 


91 


n 


112 


fl 133 




G 


71 


a^ 


92 


• 


113 


13 134 




H 


72 


] 


93 




114 


f5 135 




1 


73 


t 


94 


^j 


115 


17 136 




J 


74 


<- 


95 


1 


111 


f2 137 




K 


75 


— 


96 


1 


117 


14 138 




1 


76 


i^ 


97 


N • 


118 


16 139 




M 


77 


1 


98 


o • 


119 


18 140 




N 


78 




99 


,♦ ■ 


120 






O 


79 


1 


100 


il ^ 


21 


1 SWITCH TO WKBM 

1 UPPER CASE UiEH 




P 


80 




101 


22 


143 




Q 


81 


~— 


102 


1 


23 


QQ 144 




R 


82 




103 


ffl 1 


24 


^^ 145 




S 


83 




104 


1 1 


25 


^ 146 




T 


84 


^ 


105 

1^ 


rr 1 

6 


26 


H 147 





PRINTS CHR$ 


PRINTS CHR$ 


PRINTS CHR$ 


PRINTS CHRS 


@ 148 


IS3 1 


59 


1 170 


1 


181 


149 


^^^« ' 


160 


- 171 


1 


182 


150 


c • 


161 


id 172 


™ 


183 


151 


y ' 


162 


rq 173 


L. 


184 


152 


p 


163 


^ 174 


u 


185 


153 


LI 


164 


M 175 


U 


186 


154 


1 


165 


H 176 


bJ 


187 


155 


8tt 


166 


-L 177 


n 


188 


H 156 




167 


rr 178 


J 


189 


M 157 


b«l 


168 


r 1 179 


\ 


190 


D3 158 


n 


169 


fj 180 


5 


191 



147 



APPENDIX K: 

DERIVING MATHEMATICAL FUNCTIONS 

Fungtions that are not intrinsic to VIC BASIC may be caicuJated as follows: 



FUNCTJON 


VIC BASIC EQUIVALENT 


SECANT 


SEC(X) = 1/C0S{X} 


COSECANT 


CSC(X) = 1/SIN{X) 


COTANGENT 


COT(X)^in-AN(X) 


INVERSE SINE 


ARCSIN(X) = ATN(X/SQR{ - X*X + 1)) 


INVERSE COSINE 


ARCCOS{X)= -ATN(X/SQR 




(-X-X + 1))+ 7r/2 


INVERSE SECANT 


ARCSEC(X) ^ ATN(X/SQR[X^X- 1)) 


INVERSE COSECANT 


ARCCSC(X) = ATN(XySQR(X 'X - 1)) 




+ (SGN(X)-1)* ?r/2 


INVERSE COTANGENT 


ARCOT(X) = ATN(X) + 7tf2 


HYPERBOLIC SINE 


SINH(X) = {EXP(X)^EXP(-X))/2 


HYPERBOLIC COSINE 


COSH(X) = [EXP(X) + EXP( - X})f2 


HYPERBOLIC TANGENT 


TANH{X) = ^EXP(-X)/{EXP(x)+ EXP 




(-Xr24l 


HYPERBOLIC SECANT 


SECH(X) = 2/(EXP(X) + EXP{ - X)) 


HYPERBOLIC COSECANT 


CSCH(X) - 2/(EXP(X) - EXP{ - X)) 


HYPERBOLIC COTANGENT 


COTH(X) = EXP( - X)/(EXP(X) 




-EXP[-X))*24 1 


AVERSE HYPERBOLIC SINE 


ARCSINH(X}- LOG(X + SQR(X'X + 1)) 


INVERSE HYPERBOLIC COSINE 


ARCCOSH(X) = LOG{X + SQR(X*X - D) 


INVERSE HYPERBOLIC TANGENT 


ARCTANH(X)^ L0G((1 +X)/(1 -X))}2 


INVERSE HYPERBOLIC SECANT 


ARCSECH(X) = LOG((SQR 




{-X'X + 1} + 1)/X) 


INVERSE HYPERBOLIC COSECANT 


ARCCSCH(X) ^ LOG((SGN(X)'SQR 




(X*X4-1)/X) 


INVERSE HYPERBOLIC COTANGENT 


ARCCOTH(XJ = LOG{(X + 1)/(X - W2 



148 



( 

c 

( 
( 
{ 
( 
( 
c 
c 

( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
( 
{ 
( 
( 
( 
( 
c 
c 



APPENDIX L: 

PINOUTS FOR INPUT/OUTPUT DEVICES 

Here fs a picture of the I/O ports on ttie VIC: 

ST .-^^ 



ts 



1 

1) Game f/0 4) Serial I/O (disk) 

2) Memory Expansion 5) Cassette 

3) Audio and Video 6) User Port (modem) 




1) GAME I/O 



I 2 J 4 

o o o o o 



o o o o 

c 7 h 



pmn 


TYPE 


NOTE 


1 


JOY0 




2 


J0Y1 




3 


J0Y2 




4 


JOYS 




5 


POTY 




6 


LIGHT PEN 




7 


+ 5V 


MAX. 100mA 


8 


GND 




9 


POTX 





149 



2) MEMORY EXPANSION 



123456789 10 1112 13 14 15 16 17 1819 20 2122 




ABCDEFHJKLMNPRSTUVWXYZ 



P1N# 


TYPE 


1 


GND 


2 


CD0 


3 


GDI 


4 


CD2 


5 


CD3 


6 


CD4 


7 


CDS 


8 


CD6 


9 


CD7 


1(j 


BLK1 


11 


BLK2 



PIN# 


TYPE 


12 




BLK3 


13 


BLK5 


14 


RAMI 


15 


RAM2 


16 


RAM3 


17 


VR/W 


18 


cntw 


19 


IRQ 


20 


NC 


21 


+ 5V 


22 


GND 



PiN# 


TYPE 


A 


GND 


B 


CA0 


C 


CA1 


D 


CA2 


E 


CAS 


F 


CA4 


H 


CAS 


J 


CA6 


K 


CA7 


L 


CA8 


M 


CA9 



PIN# 


TYPE 


N 


CAHJ 


P 


CA11 


R 


CA12 


S 


CA13 


T 


\m 


U 


1/03 


V 


S02 


w 


NMI 


X 


RESET 


Y 


NC 


2 


GND 



150 



3) AUDIO/VIDEO 




PIN# 


TYPE 


NOTE 


1 
2 
3 
4 
5 


+ 5VREG 
GND 
AUDIO 
VIDEO LOW 
VIDEO HIGH 


HJmA MAX 



4) SERIAL I/O 




PIN# 


TYPE 


1 
2 
3 
4 
5 
6 


SERIAL SRQ IN 

GND 

SERIAL ATN IN/OUT 

SERIAL CLK IN/OUT 

SERIAL DATA IN/OUT 

RESET 



5) CASSETTE 

12 3 4 5 6 



A B C D E F 



PIN# 


TYPE 


, A-1 


GND 


1 B-2 


+ 5V 


C-3 


CASSETTE MOTOR 


D-4 


CASSETTE READ 


E-5 


CASSETTE WRITE 


F-6 


CASSETTE SWITCH 



151 



6) USER I/O 



1 2 3 



5 6 7 e 9 10 11 12 



A8CDEFHJKLMN 



PIN# 


TYPE 


NOTE 


PIN# 


TYPE 


NOTE 


1 


GND 




A 


GND 




2 


+ 5V 


KSfflmA MAX. 


B 


CB1 




3 


RESET 







PB(J 




4 


JOYffl 




D 


PB1 




5 


J0Y1 




E 


PB2 




6 


J0Y2 




F 


PB3 




7 


LIGHT PEN 




H 


PB4 




8 


CASSETTE SWITCH 




J 


PBS 




9 


SERIAL ATN IN 




K 


PB6 




10 


+ 9V 


IflOmA MAX. 


L 


PB7 




11 


GND 




M 


CB2 




12 


GND 




N 


GND 





( 
{ 
( 
c 
( 
( 
c 
( 
( 
( 
c 
( 

o 



c 

o 
( 



152 



c 

( 

^ / 









XH 








y- 




























3:ll 








o 
























-r 




O LU LL 








+ 
























< 




i=i -j:d 


M CO 
J 1 


U~; 


1 


c:" 
tij 
























O 




LUaCQiOi^^Jj-ll 


o 

iJL 
























lU 




li: 21 ij^ CO Oj 


a: a; cl: ui 
























0-. 




uocE:iv:Q:^i-i-H- 
























«)i3 


a X o o u 


UQ 


uo 


























oo 


CO CO CO CO '10 CO o:< co co 


tH 
























HflQ 


»— i J-H |_H H-t H- 1 


hH »-H 


1—1 


t-H 


























>s 




_ ^ 


_ 


_ 














■ ■ 












UJ>- 


|32a©sppsi! « 


O 


























V 


•K 








c& 








\ 








¥) 




























i 




































Hf 








X 




































> 








































































i£ 




































Q 




































C 




































•■ 












Q 
























lf> 












Q 
























T-* 












^ 
























B 






























® 






£L 






























1 






■* 












X 


















c 






O © 'H 












H 


















** 






Cd CJ 11 






























1^ 






CM M -J 




































O O '■ 






q:- 
















>- 








[ij 






\- \- a: 






■-. 






CNS 










cc 








^ 






o o + 






z 






^J5 
















•• 






o o cr. 






> 






II 
















s >i^ 






" " N 






UI 






r--. 

















s 


s 






1p4 1-^ © 






■j^ 






L' 


■ t 








o 






J 


s a: 

iS LU 
E ^ 






+ 1 l^i 






a 






w 










1- 












iZ rZ 11 
11 1] u 






a. 






UI 










(/) 






J 


E : O 






a: a: " 






11 






a. 










5 






\ 


1 * LJ = " 






O Q 11 






_i 






o: 










< 






j 










Q © OQ 

n CO Z 






z 

UJ 






a 

OJ 










cc 


a: 


07 




CO 






CCi III LU 






X 






^ 


o 








CD 


Id 

1- 


1^ 
+ 


; 


1 ^i ^. 1 








Zi D X 
UJ f/j K 












IE 


N 

tH 








O 


(E 


rj 




04 






O O 'S- 






1 






U 


rZ) 








_l 


*- 




1 yi I 1 


CM 






O G II 






M 






-^ 


H 








CC 


» 


li) 




+ 






Z Z QQ 






Cl 






:£ 


O 








Q- 


D 


Ti 




1 q: -ii g 

■ LlJ t-< g 


Q 






UJ LJ Q 






U- 






UJ 


o 












* 


' 


^ 






X X Z 






t-^ 






UJ 


ah 








O 


> 
Cli 


II 


1 


1 ' 1 s 


O'J 


_ 




H 3- I 
^ r^ ED 






i--t 






'^■J LL 


II 








> 


o 


z 
> 




3 ^ "'■■ 1 




= ■ 


= 


'Tj !?-j rj 
n 11 II 




r3D 


1 




1 O 


Z 




® 


© 




U> 


a* 




H 




G 


■K ^-'. ,^-^ ^. 




^ 


II 


N 




II 'H 


UJ 




•ri 


OD 


■ ■ 


D 


-t 




i LU £ 

5 ji- I ?J 


1J 




O 


= N h- N 




T-i 


Cl 


1-t 




Cr II 


X 




(Tj 


irH 


E 


1 


v^ 


in 


CD 


^ 


O 


n (7\ it I CTi 




z 


M' 


z 


CJ 


• » ,^. 


1- 




Z 


Z 




> 


+ 


C-d 


t 


il 


^ ^ ^ 1^ 




UJ 


Cl 


UJ 


o 


CM LJ 


'D 


^Li 


UJ 


UI 


X 


1 


■:■:■ 




DJ 


E3 




"1 *^ ^rf- ■■_' 




X 


K 


X 


H 


tV, s_^ 


^ 


^ 


X 


X 


V/ (Tj 


t- 


^ 


§ ffl r-J = 'M( 




= 


= ^ :i£ ::i; 




H 


X 


1- 


'^ 


N lil 


N 


K 


H 


H 


a 


z r J 


^£i 


+ 


T = = H 11 


K h- 


H 


H UJ LU UJ 


CD 


ilr 


--. 


Q 


II 


■J UJ 


h- 


u 


i^i 


O 


a: N 


tH 


(T = H H r c 


Z Z 


Z 


Z UJ Ui UJ 


f^ 


II 


UJ 


11 


X 


U UJ 


V 


UJ 


h- II 


U 


z 


H o 


« 


> H X Z HH LL 


M Hi 


n 


1-i Cl 0- Q_ 


T^ 


-I 


'^ 


CD 


Lt: 


i: Cl 


O 


':£ 


y: D 


Q 


LU 


0"J 


CTi 


UJ z '-^ ►^ ct: o 


or a: 


ct: 


Q: LL 1J_ Lj_ 


D 


u. 


O 


IL 


k_J 


O IL 


U. 


a 


UJ IL 


U_ 


:e: ii 


11 


^ >H q: Ct Cl Ll 


Q_ Cl Q_ 


CL t-H k— ! l— 1 


H 


n 


Q_ 


j-i 


LL 


Q_ ,-. 


►— 1 


Cl 


z »- 


1— I 


Q. 


UJ Ll 


CC O a: lL Cl 








O 




















Q. 


Ol q 


> 


lL IJ_ -Si -< 


U'J *S if; IS u- -s ir^ 


D ^ 


K 


S 


fH 


IT- <3 


UI 


GJ 


'T^ IS 


CJ 


< 






© tH J^< i^ O '^ 


i-( 


rxj cv CO CO 


*■ 


o:« 


C^l 


Tt ^ Tf Ij-I 


ill 


'£' 


'L' rv 


N 


-t ir^ 


yD 


© 


Ti C-J C^J -- 


I 1^ 


1^ »-i 


1-4 


tH ^-^i 


1-1 l-l 


^ 


i-H 


T-H 


tH 


T-1 


T^ 1^ 


i-t 


1-1 


^-^ 1-1 


i-H 



153 

















































A0 
^ 






n 






















































■t 






\ 






















































CJ 






w 






















































7 






CI 

1 






















































a 






G 
















01 






































Ui 






LU 






© 










m 






































■K 






^ 






^^ 










^-t 













































G 






1-1 










o 






































it 






D_ 






■-. 










H 






































Mt 






■• 






CJ 










ill 






































A0 






OJ 






CJ 










O 






































tT 






CO 






1 










■* 






































•». 






*. 






u 










1-H 






































▼4.. 






^i-1 






UJ 










cu 






































<VI 






ru 






i£ 










II 












































1 






G 










K 






































a 






D 






X 














fO 


































m 






UJ 






■1 










T*l 




O^J 


































^ 






^ 






G 










fd 




H 









































D 






'D 










+ 




s: 


































0. 






£L 






y-, 










UJ 






































■a 






■4 






K 










II 




CO 


































\0 






(N! 






CJ 










o 




CJ 


































^ 






0:1 






CJ 










• • 




+ 


































\ 






K 






+ 










1-i 




UJ 


































m 






© 






G 










II 




ii 


































Cd 






DJ 






UJ 






S 




LJ_ 













































1 






i^ 


^^ 




"jj 



























































+ 




K 




^ 




tM 


































Ui 






UJ 






X 


if 




iM 




LU 




l\ 


































^ 






^ 






El 


II 




1 




X 




^ 
















































a 


:^ 




UJ 




H 




z 


































UL 






Q. 






^B 


*■ 




UJ 




►X- 




UJ 


































s* 






■• 






rH 


CV 




i:: 




H 




X 


































fw 






cu 






k. 


0"; 




o 




LJ_ 




1- 








© 


























f^ 






rj 






*H 


*. 




a. 




G 




® 








CD 


























•h 






*, 






t 


C4 
1 




•• 

CJ 




Z 




11 

U- 








iri 



























t 






■rH 

1 






G 

LU 


LU 




^ 




'Z 




9 








1- 


























G 













i£ 


ill 








1 




z 








G 


























UJ 






UJ 






G 


:£ 




T-H 




::£ 




■X 








G 


























:£ 


'D 




ii f >i 




X 


o 




1 




I 




X 








i« 
























,T^ 


G rf 




ro 




>« 


Q_ 




UJ 




CJ 




1 








© 
























^5S 


Q^ 


*-. 




CL 


>'. 




G 


ka 


© 


UJ 




CJ 




a: 









II 










: 














^ 


i> 


^ 




la 


^ 




^^ 


CM 


0? 


jl: 




fl 




II 






c- 


U. 












- 


in 






z 







0:^ r J 




CJ CJ 




ttH 


cr. 


i-H 


o 








.-'^.. 






r- 


z 










■ 




G 


z 


; 




z 


\- 


N 


1 




G 


1 




\ 


K 


c 


iL 




c\i 




C4 






^ 


LU 








I 







^H 








q: 





!K 


G 


H 


L 


G 




1-1 


iM 


1- 


»1 




CJ 




CJ 






UJ 


X 


ID 






— 







G 








D 


G 


1-1 


UJ 


X 


1-H 


Ul 




+ 


1 


o 


ra 




X 




X 






X 


H 


OJ 








T 





1- 








1- 


«• 


+ 


^ 


LU 


■i- 


i:; 




U 


LU 


'Zj 


■4- 




.^. 




^^'. 




s: 


h- 


+H 


iM 




in 




u 


G 








UJ 


.-^. 


G G 


Z 


G G 




Ui 


UJ 


■ ■ 


\ 




LU 




Ui 




+ 


CJ 


CJ 







1-1 








G 








tz 


r--- 


LU 


(L 


■■ 


UJ tL 




if 


L*: 


III 


LU 


C4 


1 




1 


to 


D 


«?:■ 


* 


H 


© 


II 


z 


: 


z 


19 


z 


r 


; 


■ « 


Ti 


^ 


■'■ 


G 


i^ 


IB 







o 


N 


Ui 


05 


■4:1 




«rj 


l^J 


II 


/\ 


Cd 


II 


X 


.■-^. 


.--■. 


-■-■. 


■*. 


.'^. 


..--. 


y-H. 


■ *■. 


l-H 





'if 


G 


G 


CM 




X 


(L 


D 


li:^ 


TT-I 


0:- 




a'- 


1^ 


Ci 


V 


Cd 





X 


^ 


X 


X 


X 


1 


X 


X 


X 


z 


■-_■' 


CL rr 


iH 


Q_ 


0> 




•* 


•• 


-r 


Q 


3^ 


1-1 




"Si 


X 


■■ 


,-^, 


+ 


■■ 


z 


ul 


■'-■' 


'■^t' 


''_■■ 


^ 


■-J" 


^j- 


'w' 


^ 


':^ 


It 


L. 


G 


!■ 


K 




© 


ej 


UJ 


CL 


UJ 


ffj 




OJ 


UJ 


Cd 





Q 


■F-1 


Ui 


X 


G 


G 


G 




G 


G 


G 


"* 


UJ 


■i) G 


H 


CJ Oj 




tu 


rX" 


X 




X 


'-■' 


rj 


■-^ 


X 


■:o 


■-■■ 


CO 


OJ 


X 


y- 


X 


X 


CE 




X 


X 


X 




UJ 


tit 


CJ 


1-H 


CO 


CJ m 


rH 


H 


H 


It 


H 


^.^ 


Fjj 


-•_-■ 


H 


^ 


i: 


'JLI 


^ 


H 


If; 


H 


H 


\- 


z 


1- 


K 


H 


z 


Q_ 


*. 


1 


II 


V 


1 


CM 


^ 


yj 


f— 1 


■^ 


tH 


H 


1-1 


H 





■I; 


UJ 


N 


G 


© 


1-1 


H 


H K H h- H 


H H 


H 


-I> 


G 


X 





G 


l-H 


G 


Uj 


II 


+ 


II 


Z 


D 


Z 


11 


UJ 


UJ 


/^ 


LU 


'v^ 


A 


Z 




Z 


z 


Z 


Z 


^ 


^ 


22 


Ui UJ 


X 


Ui UJ 





UJ 


^ 


tu 


UJ 


^ 


HH 


H 


t-< 


Ul 


jx: 


CL 





^ 


X 


X 


1— 1 


1— t 


i-i 


M 


hH 


HH 


l-H 


l-H 


l-H 


X 


':£ 


Cl 


j£ 


i:: 


\- 


i: G 


o 


Ll 


Jl 


Li_ 


Lj_ 


D 


Ll 


li_ 





iL. 


Ll 


G 


u_ 


u_ 


Cl: 


q:: 


iji 


Q; Cii 


l£ 


q: 


ct 


LL 





G 


G 


G 








H 


Q- 


t^ 


LU 


Mi 


h-t 





>— 1 


1^ 


LL 


»— 1 


1— 1 


0_ 


M 


1^ 


Q_ 


lL 


0- 


Q_ CL 


CL 


£L LL 


CL 


X X 


Ll 


X 


X 





X ^ 


rf 


'ij 


OJ 


CTi 


Q 


T-l 


rJ 


CO 


-^ 


^if 


r- 


ff^ 


iX» 


1-1 


Cj 


Ul 


G 


Ul 


G 


Ul 


G 


Ul 


G 


G 


G 


G 


G Ul 


S 


G - 


r- 


h- 


N 


N 


0} 


CO 


CO 


0^ 


CO OJi 


o:- 


m 


CJ 


ca 


CvJ 


rj 


G 


0J< 


G 


G 


iH 


T-1 


G 


G 


tH 


CJ 


G G 0" 


G G 


1^ 


1-1 


•i-i 


.r-i 


-.--t 


T^ 


tHI 


-^ 


T-l 


1^ 


T-H 


iM 


CJ 


Cii 


CJ 


CM 


CvJ 


CJ 


Ti 


c:i 


0-^ 


0-f 


Tf 


ITS 


tr." 


in 


ir< 


in 


in 


KO K£f 



154 





A-i 




































1 












^ 


«• 






















Ui 












v 
























1£ 












m 


M 






















o 












i 


m 






















(L 












li- 


V 


































■a 


® 






















Cxi 












+ 


01 






















n 












UJ 


+ 






















"^ 






H 






LU 


UJ 






















0^ 






X 






:^ 


UJ 






















+ 






LU 






o 


>£ 






















u 












U- 


9 






















M 






■ » 






■ ■ 


a. 






















^ 






G 






^ 


■« 






















a 






\ 






\ 


c^ 






















0- 






1-i 






Ti 


CT" 






















■« 






1 






t 


"^ 






















u 






z 






Ul 


1-H 





























> 






o 


CJ 






















^ 






LU 






+ '-■ 


+ 






















J 






o 






UJ CO 

UJ o:t 


UJ 
UJ 






















o 






Q- 






^ 


^ 






















UI 






• i 






o -* 


o 




















h- 


:£ 






T^ 






CL. -X h- 


1- Cl 




















X 


D 






J 






G X 


X " 




















liJ 


iL 






£l 






^ ^-' Ul 


UJ CJ 




















z 


■ ■ 






UJ 






1- Z 


Z CO 




















■ ■ 


Cd 






H 






U_ Z " 


•• ^ 


















H 


Cj 






i^-^ 






1^1 1—1 iZt 


© CJ 




















X 








0& 






^ \ Oj 


fX- CJ 




















LU 


*'. 






^ 






LU C J U"^ G 


G + 




















Z 


rj 






N 






LU irj ^ h- 


K Ul 


= 






*■ 














+ 






o 






^f ^ K ^ 


^ UJ 


H 






o^ 












© 


D 






H 






o u. ^r II 


li ii 


Z 






CO 












^- 


LlI 






C^ 






u_ G ::- G 


O o 


t«i 






r-* 












D 


i£ 






in 






+ LU lL 


a: Q. 


Ci: 






X 












H 


o 






u 






'■ © X u 


Q " 


EL 






-I 












1-1 


GL 






w 






i2i CJ G U_ 


U_ i?J 


•■ 






:^ 












H 


■« 






o 






'.U + £L " 


" .^i 


H 






-■-^ 












X 


N 






m 






h UJ " "» 


C) ^ 


D 






h- 












o 


f^ 






a 






iB UJ III c-j 


c:- CJ 


r 






z 












ct: 








LJ_ 






CJ iil I'J O-J 


CJ i 


ff. 






1-1 












o 


^ 






O '- 


OJ 




+ G iG ^ 


^UI 


k 






1 












u. 


1-1 






' £■ y- 


C'j 




UJ CL H C J 


CJ UJ 


Z 






hi 












ta 


1 




• * 


V X 


t.. 




LU " — 1 


1 -li:! 


: d 






r^ 












Q 


o 




© 


OJ LU 


CJ 




::£ iS H UJ 


Ui G 


1- 






fc. 












c:j 


UJ 




V 


1 Z 


1 




G V G UJ 


UJ CL 


I 






o: 












<-. 


ii 




z 


UJ " 


UJ 




Q_ U- LL lii 


^ " 




1 




~> 












tX 


o 




> 


UJ o 


UJ 




'• G O G 


D CJ 


C 


r 




in 












-:- 


Q- 


CJ 


LU 


o ^ 


o 




OJ + U- u_ 


LL c:- 


,-t" 






'6 












LU 




f?*^ 


X 




'^ ^H *■ »■ 


■■ K 


"J 


^ 














'^ 


rj 


s 


Q 


CL 1 


lL 


© 


^ CJ J cv 


r? ^ 


c 


1 




Q- 












O 


rj 


CJ 


lL 


" z 


■I 


^ 


-i + CJ CJ 0> 1 


u 






*m 












[L 




ftj 


■ ■ 


r-.j > 


c-j 


^03 


ej LU -^ CJ 


CJ UJ 




1 




© 


z 


^ 


= - 






■» 


v 


+ 


\^^ 


^ UJ 


o:i Z 


+ UJ ^- ^ 


. UJ 




] 




1^1 


^ 




W 






iH 


T-H 


o 


1-1 


^ ^ 


*►. 


UJ 


UJ ^ z -^ 


^ :£ 




1 




CJ 


L 




F 




z 


1 


+ 


LiJ 


s 


-* o 


*-i 


X 


UJ O > J 


1 G 




J 




G 


t 




f" 






Q_ 


u 


y 


a: 


1 iL 


1 


H 


:i£ {L UJ UJ 


UJ iL 








H 


t 




F^ 






Q liJ 


Ui 


o 


--^ 


UJ " 


LU 


C^i 


o " x: LU 


LiJ " 


= 




"S^ 


i-^ 


m 


1 


^i 






O H 


ii 


0- 


LU 


UJ C^J 


Lii 


Oil 


tL £' O X 


M CJ 


h 




II 


II 


t% 






iH CO 


O 




i^ 


:£ in 


2£ 


Tt 


" * LL G 


Q CO 


2 




J 


J 


z 


= 


r = 




~ 


4 © 


Cl 


fj 


o 


o c-d 


a s 


CJ Uu " u- 


LL ^ 


>- 


1 


■■ 


ii 


/"*■ 


,--■, 


.--■. .-■. 




.--^- 


05 O 


■■ 


o:^ 


0- 


{L G 


Q_ 


rj 


tD G -!■ " 


- UJ 


S ^ 




Oj 


CL' 


CC 


<r 


-. CE (E 


■s 


X 


f -J h- 




^ 


■ ■ 


" H 


1* 


+ 


K + *. Cj 


CO UJ 


s Q 




CJ 


O 


■-_■' 


'-^- 


; ■*■' V' 


= 


.^ 


^ ID 


OJ 


CJ 


•-J 


C'd CO 


CJ 


II' 


C J CJ -H CJ 


CO ■;£ 


tfl ' 


> 


■r-l 


U. 


CD 


Qi 


n CL a: 


M 


m 


K *-Hl 


© j>:i 


CJ 


+ 


'L' t 


l-J 


Cj 


CJ CJ 1 CJ 


CJ G 


t3 ^ 


^ U"; 


* 




o: 


C 


T. 


Z IE 


1! ^ 


I 


CJ 


^ ca 


K 


'£' 


+ + Z ^ 


sCl 


= 4 


' CJ 


z 


*■ 


H 


H 


- h- H 


- 


h- 


> O 


Ci O 


u 


r-i 


u ri 


Id 


r- 


-^ LU UJ > LU 


Ui " 


i- I 


:■ ^ 


> 


T^ 


H 


t 


J- 1- H 


!- 


t 


LU t:i 


" \n 


Ul 


+ 


LU G 


UJ 


V 


+ UJ UJ UJ UJ 


Ui H 


Z C 


J o 


Ui 


+ 


-X 


Z 


z z z 


Z H 


z 


:£ Oc: 


CD 1^: 


:i£ 


LU 


M u: 


■:£ 


Ui U i^ 1:^ ::::: ^ 


::£ X 


^ \ 


H 


^ 


-x 


i-H 


p—i 


k-l 1-4 M 


1- X 


1-4 


o o 


[| Q 


o 


w 


G G 


Q 


u_ 


11 G G G G 


G Ui 


Cl r 


J G 


G 


II 


OL 


Cl 


LL iL Ui 


q: uj 


a: 


Q_ IJ. 


m iL 


CL 


LU 


CL U- 


iL 


h-1 


UJ U_ CL LL IL 


LL Z 


iL C 


It G 


Cl 


I 


Cl 


Cl 


iL LL iL 


CL X 


CL 



S *-> iD ^ t^- G l3~i '£> ^- G ^ i" J »"0 ^ EO 'X^ f^- Oj iTi S G -^ ^ Ei"i Ij"j G U"j Lj"' G \ff 
rt ^ rt 1-1 Ol 1-^ ^ t -t ^ IT^ li"J U'l IT' U"f lJ"J ii:i Li"J in li^i 10 G G G G -h i?iJ CJ CO ^ -t 
IJ5 ^£i ^0 'JJ CO *D '£i ^£' yj" *-J:f '■i> ^i5 'JIi ^£< ^D 'Xi 'ii '■!> \D '■!:" ID fv r- F^- f^- N I'- N fv f'- I - 



155 



f 



s 

H 
i 
i 



£L 






+ 
Ul 

n 



bJ 

Ui 
X 
H 
ID 






It 

Q 
CM 

I 
Id 

II 



m 

+ 

■M 
CM 




1^1 -•-* C-J ^jj CM 

[11 in in IT' l^^ 
N ^- h- h- r. 

























m 














i^H 






Ct^ 








+ 






UJ 

1— 








P 






•r 








M5 






»i 








^)M' 




1- 


LU 








0^ 


^ 


X 


2:1:0 








III 


y^. 


UJ 


■X -^ 








^sC 


UJ 


X 


3iLj~f 








^0 


*y- 




i^— 1 








CL 


■• 


^- 


+ 








... 


1- 


^-c 


fvi 








© 


X 


UJ 


>^ 








n 


u 


X 


m 'Ii <Si 




h- 




X 


X 




-1 II 




:< 




X 




T^ 


■*-»- 




LU 




u 


1-1 


+ 


*Ti ■* 




X 




X 


+ 


ij_ 


UJ = 








w 


U- 


c*j 11 


1:^* 




'^'H 




"S 


II 


CvjU. 


0^ 




-, 




H 


u. 


Q_ 


CU* 




IX 


1— 


V 




UJ ^-% 


H- ■ 




Ul 


"x* 


«« 




1-lL 


LU "_f 




^ 


ui 


Ll_ 


C-.J 


CO -^ 


2: II 1- 




c< 


X 


1— i 


'TO 


^i:q 


0_l LU 




ij^ 






-. 


'I- - 


U^ ^ = 






■Hi 


ro 


R 


on 


^ Ci> 




k-li 


'Xi 


1 


UJ 


h-UJ 


a: .^. 1 1 LU 




Q 


1—1 


:d 


':;£ 


CtlO"::^ 


LU «%j ::i:: 




b^j 


n 


w li: 





II 


_l— ' Ct 




+ 


.--■. 


x-o 


u_ 


UiUlCL 


_J w UJ > 




■Hi 


iX 


- UJ 


CJ ■ 


i-q: ■■ 


i-tPQ_j2: 




1^1 


'■^^ 


3^- 


i:j ui 


UJQUi 


j^ ^ ^ iX 




^ 


CQ 


- UJ 0- + 


xll + 


1— 1 i-H 




CO 




M-x 


UJ '"■'' 


■ CO 


Q ^ 1— 




C'J 


'-.J 


'-H 


1- + 


XQ + 


K-i 


'Si 







IT' + 'X 


f.o ■::' 


■X ^L^ 


=^ '^Jj * X 


".£1 »- 




t>J 0> Cl' ^ 


QL 1-4 




'T—i 


Tf 


Ci 


X^UI'TI- 


Q - 1- 


-. 


1- 


1- tu '-O 


OUJ 


LTiU 


a. 


rr 




x-^:e: 


\- + 


X K + 


r- 


OJ 


,^H 


l-*U 


■r 1 u 


UJ--0 


2 ixi = = 


T-l 


1:0 


11 


'3 a 1 a: 


II il -H 


q: cc« 11 


^O'j^h- CO 


11 


'X 


11 UJ ■ 


UJQ + 


■ UJi=i 


- ^D 2: :r 


UJ 


■X 


Q: 


X!:^ — 


ct: 1::^ C 


1^ :-;q: 


^ TX, l-H l-l 


■::^ 


Qi 





U.O 11 


n 


11 00 


Ul 11 £H ct: 


l*-l 


' Li, 


•-H IX LJ_ IL LL C 


LutJLU- 


cl' a_ ix cl ll 











'X* — ' *^ ro CO «T I 



156 



■zj q -^ i/j in ^0 rv 0:1 cr-i "S in 

-H i'^j rij r-MJ r .J r^ij i"-.J AJ i"iJ CCi iTi 



Gj 


© 


u-j 


o 


!- 


O 


o 


Cj 


UJ 


> 


o 


ct: 


1— 


to 


Ld '-^ 


Qi>J 


* 


LUOJ 


COOJ 


a: + 


miT' 


1^ 


:z: + 


ocs:' 


o *:o 


5*-p 


S 1' 


s to 




n ^ 


= II 


!-0 


ZIX 


1^ LU 


q:x 


iLk- 


IZIi^ 


u u 


xo 


1- o 


SI 2: 


10 a: 


-i-f = 


" = 


^ /\ 


CO V 


rw^ 


-i"r 


CCiU^ 


v.-- 1-1 


■s^ ., 


Hi ¥^ 


UJOC 


Q.K 


U-LU 


I-H tD 



OJ 

I 

I a 

■Xi to 

LU ■>] 

I— '^ 
G' CO 
II LU 

Li_ i_i 



00 

o 
•r 

00 o 
o " 

O -H 

o u 
tri ■■ 

II Q 

^' + 
tS> CO 

© c- J 

+ - 
CO »:o 

^ + 
- CO 

^ VD 

+ -H 

CO * 

^ IJI 

1.0 UJ 

^ o 

Lii ■ 

%£ i-H 

O II 
Q_ li 



II + 

- w 
+ • 

H C ■} 

n CO 



■:!* I 
II to 
Ci u 
., '^ 

M o 

^j CL 

DJLU II 
1-0 X 
ox X 

■' LlJ I— 
iXjX CIi 
II t" 'Jj 

O iXi *-* 
X'D U 
LU ---H .^'. 

X n -« 

H-^-v 1 
' £" O'J to 
^ ■■„■■ '■_'' 

r-muj 

■ V ■ bJ LU 

tOCL LL 

Li_tJ^ Ll 



II 



LU 



C>] 
CO 
11 

IJL 

tu 

X 

1— 

CJ 
LI 



UJ 

u 



CM UJ V" 

G_ + >: 

UJ CO LU 

t— + X 
to o ' ■ 

-^ I— X 
OLULU 
I— + X 

II II -^ 

lUf^ + 

[±:a:u. 

i?.J O 13 w 



X 

LU 



CD 
CO 

o 

LI 

q; 

CiT 

inct; 
+ o 

■jCiLl 

l%J ■ ^»-H 

V-4U0 I 

-. -. a_ 
i:o '^ LU 
—I T^ J — 
+ + to 

i"\ CO © 
^*" o 
".jli 'U I- 

.^ i-H IT* 

* * -^ 

^ a-i a-i II 

c »J U LU 'X 
O Jii ii^ (J^ 

J— C» *_' '^^ 



H-, HH i-H CL U^ "^ O U. Ll Ll 



O 13 U O Cl Cl Ll 



IX> Gi 'S« Ul 1^! Si -H 

00 -r itj in 'o r^ r^- 



iS 



y> Si ^^ U' C"-] ^ ^£i 

r^- 1 jd ixi o OD o:* oo 



S* LlO ^^ 
O ^Si S* ■'^ 

17-, in ltj Ul 



X 

iXLU 

-X 

+ s* 
^o 

'X1 1- 

■I— I -pHi 

•^ II 
a, ct:: 

LUul 

oo 

Q_LL 

-—i Si 
-n^OJ 
U"J UO 



a: 



X 
UJ 



'>J 



11 

ur 
yr_ ct: 

UJO 
X Ll, 

i3 i3 
CO ^ 
Lt"i U"* 



157 



in 

CM 

+ 

00 
CM 



■XI 

CO 
1^1 



U"' 



o 



m 









i 



€0 



LU 

:^ 
o 



II 



I 

o 
fj 
o 



CM 

CO 



M 

o 



CO 






CO 



r-- 



*£i 
II 

I 

n 



C*J 



'J.I 



T— i 



ct; 



X 








S 




-. 


ill 




di 
















H 


UJ 








X 




CM 


:-£ 




















X 


> ::: 








Ki' 




CM 


u 




GS 
















N-i 


(:q 








in 




+ 







m 
















^^ 


■xi 








^l- 




':-i 

UJ 


a: 




















+ 


^'=^ 








s ^ 




1*: 


UJ 




_i 












1Q 




ID 


nuj 




= 




>: -^ 




Ci 


ui 




CO 












Is- 




r- 


= j^ 




^ 




lE" t— 




LU 


^ 






















r- 


HO 




i^ 




w j- 






^ 




Ci 












t- 




n 


Q :r o_ 




* 




if^ 




■^^ 


Tt ^D 




X ■ 

















iL. 


::^ 1^ .. 










M 


wi .0 




LU ^!I* 












.0 






x CL i:o 




1=1 




5j +- 




cq 


+ CO s 

CO -1 g 




X^ 
















.^H 


^ Q_ rj 




--7- 




X 4" 




IZ 




1— — 












{^ 




1 


z: ■' * 




iX 




.■c^ -'H 




u 


^ + g 




CM 












(S 




u 


O Si OJ 




CO z: 


3 


St^ 




X 


vo coH 




'OH 












yri 




u 


CJ CO Cvj 




+ e: 


> 


^£; 




H 






11 1=1 












|£) 




X 


, »ii + 




c d 


UJ 






Q 


^^X^S 




■ -^ 












_* 




LU 


h ^':- '^' 




CO Q 


i£ 


m- ^m 




u 


IJ ! -^ S 




Pi - 










'D 


CO 




X 


LU 1 13 




+ 




tU ^m 




iM 


u *W 




■■_ ' iD 










r- 







1- 


lis: Q ^3- 




^1- 


> 


^ S 




i=* 


i£: ij'i i 




:i^ n 













C; 




T- 4 


o o 1:0 




■XI u 


^ 


Kf' M 




^ 


UJ H 




UJ w 










H 


X 




w 


^ CO 




+ :ii 


X 


i- 




IX 


D_ ::^x 




u:r 













UJ 






cl: CO ID b"* 


CO 




ij-:« 


z 


. o-H 




CM 0_ UJ 








UJO 


XiD 




CM 


col- 


■^H 


C>J Ci 1— 


f-1 


r 


^ LJ-Lt: 




c .i q: X 








+ 




1— r-> 




■* 


li i>j 


+ 


-^q: 


1— i 


'^ S 


+ 


.\ 


1 - lL 




1 01- 




^D 




U- 


iDi 


iDO 




/^. 


Ll cj 


S 


+ 


X 


^ S 


i?*j 


V 


^iDX 


G. 


« i:d 0:1 




iD 


ID 


Jl 


ji 


CO H 




i«i 


= + 


Cyj 


'D^ 




is 


C-.J 


4H*t 


II II Ui 


-.-H 


11 'DOj 




C'j r- 


U.X 


u 




'■_' 


3 3 '^' '-' 


* 


- * 




* 


*r 


_l lilX 


-^H 


Q 11 + 




X 


X 




X 


. - . ij3 




Q 


:vj 111 ± 




1" 


oj 


U- 


2: XI- 


-T- 


■ --.ID 


sD 


u u 


CM UJ U, ■ 




X 


5 5 -e ^ 

S 3 ;:S ;:^; 


■J 


T5S 




C-.J 


*-H 


U UJ-H 


U 


C .J Q iX 


CO X X 


CO X 


■_ ID 




Ql 


+ 




+ 




X X C -j 


X 


CO ' -- 'Xi 




H 


1- 




h- 


:^ - 






Z' 


l^H Z 


=- 


'^ ~ 


■D 


¥t 


l~ 1- ^ 


H 


- i^^ r '- 


1=1 'D 


iD 


U_ 


HH 


UJ Lu 




H- 


:o 


> H 


H 


tt 


CCi 


<r 


—1 ID CO 


ID ^=i LU ^/ 


L^ 


II 


II 


U 


II 


UUJ 




X 


* * '?*■ '=c 


£1 


u:z; 


^ 


^ ^ 


'.£1 




II II II :z: 


II 


UliJi=f 


i:^ 


X 


X 


j^ 


U_ 


LU 2^ 


^^H 


1— 1 


= = II a: 


r-- 


1^ 1-4 


1— 1 


1— 1 HH 


r-^ 


1- 


1:l:: _i 3 m 


::k:cLU_ 





u. u_ 





Lu luO 


II 


u_ 


^ ^ 1— 1 


II 


Lti Ct: Cl; Lt: 


11 


u 


U_U_U.Q:U.iDU.^ 


LL 


i^-p 


1—1 


LU 


1— 1 


'-ILL 


X 


I^H 


UJ UI ::- Lu 


'^i 


U_ tJL 


LL 


clclo: 


ID 


£i 1— * >— 1 1— 1 ' ■ 


i~i 


lL*-" 


















ct;ci^ ^ 














-1 H 




1:1:1 liO iD 


U-t 


ixi y-i 


ID «Xi ID bl 


Gl -.-H 


[T} 





u-i 


ID ID 


'D 


ID 


It -4 CM u"i y-: 


Q U",| iD ID 


ID 


'^^ 


■^H 


Cd 


CJ CO ^ 


D 


i5 


^^ |%J ^4 _, 


'^ 


rj rr, 


|"i 


^m 


'£1 


r--. 


_i r - r-^ r - u 


CO CCi '7 . ^ 




-H 


'-H 


■■-^ 




— ^ — 1 


"d 


■^.j 



158 






O 



C.J 

I 

O 



r-i 

r-j 

I 

ll 

LU 

o 



ir-.j 






1-1 










CL 
















'D 






-. 


























ir 






O-J 










|>J 
















o 






+ 










«:o 
















T-J 






u. 










C'J 
















CJ 






LU 










i?j 
















+ 






liiii 










+ 






1— 










Ll 




rt 


o 










u_o 






:--c 










II 




'. 


CL 










lu - 






LU 










l-H 






^Xi 










::£U_ 






I^ 










OJ 




+ 


Ml 










CL + 






<ii 










OJ 




0>-4 


--H 










■ ■ 1-1 






'£i 










* 




KO 1 


-, 










OJ 1 






o 














= Li_ 


'— 1 










«:o y^ 






k- 










'XI 




LU 


1 










-.LU 






—4 










+ 




11 ':^ 


Tfb. 










^ ■::^ O 






II 














Ci 


~. uu 










1 c* - 






— l 










ixi 




iLJCi- LL'::^ 










U„U_U_ 






o 










1—1 




q: 


o c< 










LU ■ O 






m 










"^ 




o^ 


+ a. 










:i^^3 + 






rri 










■■-^ 




'_> ■ 


OJ ■ ' 










O - C J 




C J Ll 








bi 


■I— 1 




ji'UL 


-M 'S:- 










Q_ LL «>J 




OJ 










OJ 


■'_'* 




So 


1 ".£( 


UTi 






1— 


- O 1 




u 


o 








T-H 


fi 






Ll^ 


'TO 






X. 


OJ + Ll 




UJ 


-+ 








+ 


z: 




K' 1—4 


UJ '. 


+ 






LU 


ro ^ UJ 




}- 


X 








CO 


Lt; 




k1^ + 


1£-H 


CO 






2: 


- + 1^ 




CO o 








l-.J 






W. Ll 


Ci + 


i:.j 


—I 






-t u o 




' D LU 








-^r-i 


K 




= LjJ ClLl 


-*— 1 


1 


> 


h- 


+ UIU. 


'Zl 


1—* 


^ 








- 


X 




K 1^ 


.- LU 


-. 


LL 




!■< 


LlIc: ' 


-, 


it^ 


Ci 


h- 






CO 


l—i 




2:ci 


^ i^ 


ro bJ Tj- UJ LU '=■ ^Xi 


CO 


0-J 


u_ 


1:- 






■»— 1 


'■-' 




-HLL 


- O 


-^H 


1— 


■^H 


^ 


::^LL -. 


-^4 


OJ 




ui 






+ 


+ 




ct: 


r-j CL 


+ 


u:- 


+ 




■Zr ' C .J 


+ 


+ 


,"'. 


:z: 






CO 


'3 




CL^ 


I'-j ■ ' 


"Ti 


1^ 


Ml 


Cf 


LL '2^1 CpJ 


c^' 


u 


X 








^ 


lAi 






+ iZi 


^Lj, 


'D 


+f- 


OJ 


■' -. + 


^ 


o 


Ci 


1— * 






'b 


•1- 




O Ll U- ' £' 


'.£i 


^- 


'b 


l-l 


i: .J u u 


'b 


1- 


■'_■' 


^-l 






T— ( 


r- 


■:ij 


■^H l_l 


o^ 


-—H 


Mi 


-^H 


H 


'■0 Ci c 


1—1 


u_ 


^ 


-. 






^ 


H 


II 


+ + 


+ - 


^ 


1^ 


* 


1— f 


-. + + 


* 


II 


LU X 


-T- 


<::i 


■7, 


LL X 


Ct Ll Ll Ll 


a. 


ir 


rT, 


Jl 


Li,Li_li_ 


17. 


XLU 


Ci 


cZ 


f- 


U 






ify Ui Ld LU LU 


> 


UJ Q_ UJ LU LU UI 


C' 


LL 


U 


=1 


o 


::x; 


11 n 
Ly to 


11 -^ 

i 'i i~( 


1 — i \~^ 


. — 1 


lL 


:2^ 


■^ 




t— . 


CL 


II 


Jl 

l'"! 


1- 

LU 

Ltl 




o 
a. 


"J'l D_ 


llClClu,llLl 


a,LLO- 


OL 


u 


1 — 1 


I' — ' 

Cl 


Cl 


ci 


'Xi 


w .-.J 


TO iXi 


1-^ 


CJ 


TO 


^ 


Q 1-1 i/.J 


-ro 


ISI^ 


'D 


O 


a. 


iB 


i-H 


'::i 


':it iZi 


i'2ii --H 


T-J 


CJ 


OJCJ 


':o «:o '"r« 


CO 


Tj-TT 


^ 


'Xi 


17-1 


iZi 


r J Lj^- 


b^^ U-i 


m u~i 


Ul 


u-i 


u-i 


U-t 


LJ-) Lj-i IJ^* 


uo 


b"! 


U-- 


uo 


CO 


a. 





*3:^ 



I : 

Cl . 
LU- 

)—■ 
ilO 
i^ I 

l_l ■ 

h- 

'D 

1-HI 
II 

I*" 

uC 
|_J 

LL 



+ 
CO 



leD 



LU 

<_i 
CL : 



c^ 



Cl UJ 

CL z: 



UJ 

a: 
o*j 



159 



( 
APPENDIX N: ERROR MESSAGES ^ 

This appendix contains a complete list of the error messages ( 

generated by the VIC, with a description of the causes. 

c 

BAD DATA, ..String data was received from an open ftte, but the pro* 

gram was expecting numeric data. { 



BAD SUBSCRIPT.. .The program was trying to reference an element of ( 

an array whose number is outside of the range specified in the DIM 
statement. 



t 

CANT CONTINUE. ..The CONT command will not work, either ' 

because the program was never RUN, there has been an error, or a ^ 

line has been edited. 

( 
DEVICE NOT PRESENT... The required I/O device was not available for 
an OPEN, CLOSE, CMD, PRINT#. INPUT#, or GET#. < 



DIVISION BY ZERO.., Division by zero is a mathematical oddity and 
not allowed. 



FILE NOT OPEN The file specified in a CLOSE, CMD. PRfNT#, IN- 

PUT#, or GET#. must first be OPENed. 



ILLEGAL DIRECT.. The INPUT statement can only be used within a 
program, and not in direct mode. 



loops or having a variable name in a NEXT statement that doesn't cor- 
respond with one in a FOR statement. 



160 



EXTRA IGNORED.. .Too many items of data were typed in response to ( 

an INPUT statement. Only the first few items were accepted. 

( 
FILE NOT FOUND. ..If you were looking for a file on tape, and END- 
OF-TAPE marker was found. If you were looking on disk, no file with ( 

that name exists. 

( 

FiLE OPEN.. .An attempt was made to open a file using thG number of 

an already open file. ( 

FORMULA TOO COMPLEX. ..The string expression being evaluated ( 

should be split into at least two parts for the system to work with. 

( 

ILLEGAL QUANTITY. ..A number used as the argument of a function 

Of statement is out of the allowable range. { 

LOAD.. .There is a problem with the program on tape. ( 

NEXT WITHOUT FOR.. .This is caused by either incorrectly nesting ( 



NOT INPUT FILE.. .An attempt was made to INPUT or GET data from a 

file which was specified to be for output only. f 



( 
( 



( 
( 

( NOT OUTPUT FILE., .An attempt was made to PRINT data to a file 

which was specified as input only. 

OUT OF DATA.,. A READ statement was executed but there is no data 
( left unREAD in a DATA statement. 

OUT OF MEMORY... There is no more RAM available for program or 
variables. This may also occur when too many FOR loops have been 
nested, or when there are too many GOSUBs in effect. 

OVERFLOW... The result of a computation is larger than the targest 
number allowed, which is 1.701 41884E + 38. 

BEDIMED ARRAY.. .An array may only be DIMensioned once. If an ar 
ray variable is used before that array is DlM'd, an automatic DIM 
operation is performed on that array setting the number of elements 
to ten, and any subsequent DIMs will cause this error 

REDO FROM START... Character data was typed in during an INPUT 
statement when numeric data was expected. Just re-type the entry so 
that it is correct, and the program will continue by itself. 



RETURN WITHOUT GOSUB...A RETURN statement was encountered, 
and no GOSUB command has been issued. 

STRING TOO LONG... A string can contain up to 255 characters, 

SYNTAX... A statement is unrecognizable by the VIC. A missing or ex- 
tra parenthesis, misspelled keywords, etc. 

TYPE MISMATCH. ..This error occurs when a number is used in place 
of a string, or vice-versa. 

UNDEF'D FUNCTION... A user defined function was referenced, but it 
has never been defined using the DEF FN statement. 

UNDEF'D STATEMENT.. .An attempt was made to GOTO or GOSUB or 
RUN a line number that doesn't exist. 

VERIFY.., The program on tape or disk does not match the program 
currently in memory. 



161 



INDEX 

A 

Abbreviations. BASIC commands 133 

Accessories 106. 109 

Addition 24, 115 

AND operator 115 

Animation 50. 51-66, 99, 139, 143 

Arithmetic Operators 24, 1 16 

Arithmetic Formulas 24, 115, 123, 148 

Arrays 114 120 

ASCfuntion 131, 145 

ASCII character codes 145 

ATM function 129 

B 

BASIC 

abbreviations 133 

commands 115 

operators 115 

statements 119 

variables 86, 113 
Buffer 110 



Calculatfons 24 

Cassette tape recorder 107, 109 

Cassette port 106 

CHR$ function 102, 131, 145 

CLR statement 119 

CLR/ HOME key 6. 18 

Gfock114 

CLOSE statement 110, 119 

Color 

Keys 19, 32 

Memory map 63, 143-144 

Screen and Border 33, 36, 38, 39, 134 
Commands, BASIC 115 
Commodore key (see graphics key) 
Connecting the VIC to TV / monitor V 
CONT command 115 
CTRL key 18 
CRSR keys 18, 60 
Correcting errors 8, 50 
Cursor 3, 18, 60 
cosine function 129 



Editing programs 8, 50 
END statement 121 
Equal, not-equal'to sign 115 
Equations 115 
Error Messages 6, 160 
Expansion port 106^ 149 
Exponent function 129 
Exponentiation 115 



Files, cassette tape 109 
FOR statement 121 
FOR,„.NEXT loop 121 
FRE function 132 
Functions 129 



Games to try 153 

Game controls 108 

Game port 108, 149 

GET statement 89, 122 

GEJU statement 123, 111 

Getting started V, 3 

GOSUB statement 123 

GOTO statement 123 

Graphic keys 14, 19 

Graphic symt^ols 14, 142, 146-147 

Greater than 115 



H 

Hyperbolic ftjnctions 148 



I 

IEEE-4S8 Interface 107 
IF..THEN statement 123 
INPUT statement 84, 124 
INPUT# statement 111 
INSert key 3, 8, 19 
INTeger function 129 
Integer variables 113 
I /O pinouts 149 
I/O ports 106, 149 



DATA statement 79, 119 

Data, saving & retrieving from tape 109 

DEFIne statement 120 

Delay Loop 55, 78, 96 

DELete key 3, S, 19 

Dimension statement 120 

Divisfon 115. 160 

Duration (see FOR....NEXT) 



Joysticks 108 
Keyboard 17-20 



c 



162 



c 



^ 



LEFTS function 131 

LENgth function 131 

Less than 115 

LET statement 124 

Line numbers 78 

LIST command 8. 9, 50, 116 

LOAD command 109, 1 16 

Loading programs on tape 109 

LOGarithm functfon 130 

Loops, time deiay 55. 78. 96 

Lower case ctiaracters 20 



M 

Mailing label program 92 
Mathematics 

formulas 24, 115, 123, 148,160 

function table 148 

symbols 115 
Memory 36. 80, 125, 126, 130 
Memory expansion 107 
MID$ function 43, 131 
Modulator. RF Vj 
Multiplication 115 
Music 

pitch 68 

sound effects 135 

table of notes 73 

VIC piano 75 

writing songs 77 



N 

Names 

program 109 

variable 86 
Nested Loops 122 
NEW command 7 
NEXT statement 125 
Noise 71. 74 
NOT operator 115 
Numbers 23, 24, 115. 123 
Numeric variables 86. 113 



ON statement 125 
OPEN statement 126 
Operators 
Arithmetic 24, 114 
Logical 115 
Relational 115 



Parentheses 115 

PEEK function 130 

Peripherals 106 

Pi 20 

POKE statement 36. 80, 125 

Ports, I /O 149 

POS function 132 

PRlNTstatement 5, 21, 127 

PRINT# ^27 

Programs 

editing 8, 50 

line numbering 79 

loading / saving on tape 109 
Prompt 84 



Quotation marks 96 



Random numbers 40, 43, 103 
READ statement 79, 128 
REMark statement 128 
Reserved Words 86 
Reset (see Restore Key) 
Restore key 17, 26 
RESTORE statement 128 
Return key 18 
RETURN statement 128 
RIGHTS function 132 
RND function 40,43, 130 
ROCKET COMMAND program 153 
RUN command 117 
RUN /STOP key 19 



SAVE command 109, 117 

Saving programs on tape 109 

Screen memory maps 63, 143-144 

Serial bus 107 

SGN function 130 

Shift key 18 

SiNe function 131 

Sound ejects 135 

SPG function 132 

SQR function 131 

ST system variable 86 

Stop key 19 

STOP command 128 

String variables 42. 86, 113 

STRS function 132 

Subscripted Variables 114 

Subtraction 115 

SYS statement 128 

Syntax Error 6 



163 



TAB function 132 

TAN function 131 

Tape Cassette operation 109 

Tl variable 114 

TIS variable 114 

TEme, setting VIC clock 114 

TO in BASIC statements 121 

Tones 70 

TV, connecting tfie VIC V 



U 

Upper / lower case mode 20 

USR function 131 

User-defined function (DEF) 120 



VALue function 132 
Variables 

Array 114 

Floating point 113 

Integer 113 

Numeric 86, 113 

String 42. 86, 113 
VERIFY command 109, 118 
VICTIPS 3, 8, 16, 39h 40, 47, 50, 78, 96 
VIC person {see animation) 
Video port / connections V. 150 
Volume 69. 71, 72 



W 

WAIT statement 129 
Writing to tape 109 

Y 

Your Name in Lights (program) 95 

( 
( 
( 
( 
( 
( 
( 
( 

164 ^ 



) 
) 
) 
) 
:> 

:> 

> 
) 
) 
) 
) 

> 

) 
> 
) 
) 
) 
) 
:> 
) 
) 
) 
) 
) 



^ • 



A"l]SER FRIENDLY" COMPUTER 

The new VIC computer ts designed to be the most 
user friendly connputer on the market, ..friendly in 
price, friendly in size, friendly to use and expand. 

With the VIC, Commodore is providing a computer 
system which helps almost anyone get involved in 
computing quickly and easily. ..with enough built-in 
expans'on features to let the system ^^grow" with the 
user as his knowledge and requirements become 
more sophisticated. 

VIC owners who wish to learn more about computing 
should ask their Commodore dealer about these 
other self ^teaching and reference materials: 

• VIC LEARNING SERIES,, .a library of self-teaching 
books and tapes/cartridges which help you learn 
about computing and other subjects. Volume I in the 
VIC Learning Series is called 'Introduction to 
Computing.,, On the VIC". Volume II is called 
^Introduction to BASIC Programming". Subsequent 
titles will include Animation, Sound and Music, and 
more, 

• VIC PROGRAMMER'S REFERENCE GUIDE...a 
comprehensive guide to the VIC20 Personal 
Computer, including important information for new 
and experienced programmers alike. 

. VIC-PROGRAM TAPES, CARTRIDGES AND 
DlSKS„.a growing library of recreational, 
educational and home utility programs which let you 
use the VIC to solve problems, develop learning 
skills, and play exciting television games. These 
easy4o-use programs require no previous computer 
experience. 



^t commodore 

^ COMPUTER